-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathassert.cpp
More file actions
44 lines (39 loc) · 1.16 KB
/
assert.cpp
File metadata and controls
44 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// assert.cpp
// OpenAttributeGraphCxx
#include <OpenAttributeGraphCxx/Misc/assert.hpp>
#include <OpenAttributeGraphCxx/Misc/log.hpp>
#include <OpenAttributeGraphCxx/Graph/Graph.hpp>
#include <stdio.h>
#include <stdlib.h>
static char* error_message = nullptr;
namespace OAG {
void precondition_failure(const char *format, ...) {
char* s = nullptr;
va_list va;
va_start(va, format);
vasprintf(&s, format, va);
va_end(va);
if (s != nullptr) {
platform_log_error(error_log(), "precondition failure: %s", s);
Graph::trace_assertion_failure(true, "precondition failure: %s", s);
if (error_message == nullptr) {
asprintf(&error_message, "OpenAttributeGraph precondition failure: %s.\n", s);
}
free(s);
}
abort();
}
void non_fatal_precondition_failure(const char *format, ...) {
char* s = nullptr;
va_list va;
va_start(va, format);
vasprintf(&s, format, va);
va_end(va);
if (s != nullptr) {
platform_log_fault(error_log(), "precondition failure: %s", s);
Graph::trace_assertion_failure(false, "precondition failure: %s", s);
free(s);
}
}
} /* OAG */