Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
error_codes_def.hpp
Go to the documentation of this file.
1#pragma once
2
3#define SYS_VM_OPEN_NAMESPACE namespace sysio::vm {
4#define SYS_VM_CLOSE_NAMESPACE }
5
6#include "error_codes_pp.hpp"
7
8// create a category for parser error codes
9GENERATE_ERROR_CATEGORY(parser_errors, "sys-vm parser errors")
10GENERATE_ERROR_CATEGORY(memory_errors, "sys-vm memory errors")
11GENERATE_ERROR_CATEGORY(system_errors, "sys-vm system errors")
12GENERATE_ERROR_CATEGORY(auxiliary_errors, "sys-vm auxiliary errors")
13
14// clang-format off
15#define PARSER_ERRORS(macro) \
16 macro(parser_errors, invalid_magic_number) \
17 macro(parser_errors, invalid_version) \
18 macro(parser_errors, invalid_section_id) \
19 macro(parser_errors, general_parsing_failure)
20
21#define MEMORY_ERRORS(macro) \
22 macro(memory_errors, bad_alloc) \
23 macro(memory_errors, double_free)
24
25#define SYSTEM_ERRORS(macro) \
26 macro(system_errors, constructor_failure) \
27 macro(system_errors, unimplemented_failure)
28
29#define AUXILIARY_ERRORS(macro) \
30 macro(auxiliary_errors, checktime)
31
32// clang-format on
33
37CREATE_ERROR_CODES(auxiliary_errors, AUXILIARY_ERRORS)
38
39#define _SYS_VM_ASSERT(expr, err_type) \
40 if (!UNLIKELY(expr)) { \
41 return err_type; \
42 }
43
44// assert but invalidate the enclosing class
45#define SYS_VM_ASSERT_INVALIDATE(expr, err_type) \
46 if (_valid = false; !UNLIKELY(expr)) { \
47 return err_type; \
48 }
#define MEMORY_ERRORS(macro)
#define AUXILIARY_ERRORS(macro)
#define PARSER_ERRORS(macro)
#define SYSTEM_ERRORS(macro)
#define CREATE_ERROR_CODES(CATEGORY, ERRORS)
#define GENERATE_ERROR_CATEGORY(CATEGORY, NAME)