valeri/src/error.hpp

35 lines
811 B
C++
Raw Normal View History

#pragma once
enum class ErrorCode {
Success,
2024-07-27 00:01:38 +00:00
OutOfMemory,
2024-07-27 15:25:44 +00:00
IndexOutOfRange,
TypeMismatch,
2024-07-27 22:13:59 +00:00
ReadError,
UnterminatedStringLiteral,
2024-07-28 16:54:04 +00:00
InvalidNumericLiteral,
NotImplemented,
InvalidSymbol,
MalformedList,
2024-08-01 21:45:16 +00:00
KeyError,
EndOfProgram,
2024-08-15 00:18:05 +00:00
CompilationError,
ArgumentCountMismatch,
IOError,
2024-08-26 12:16:05 +00:00
Interrupt,
AssertionFailed,
DivisionByZero,
};
2024-08-10 10:17:20 +00:00
void seterr(const char* err);
const char* geterr(void);
#define STRINGIZE_NESTED(A) #A
#define STRINGIZE(A) STRINGIZE_NESTED(A)
#define ERROR(code) \
(({ \
seterr("Error " STRINGIZE(code) " at " __FILE__ ":" STRINGIZE(__LINE__)); \
ErrorCode::code; \
}))