2024-09-19 00:52:55 +03:00
|
|
|
const assert = @import("std").debug.assert;
|
|
|
|
const MalType = @import("types.zig").MalType;
|
|
|
|
|
2019-12-08 23:07:41 +03:00
|
|
|
pub const MalError = error {
|
|
|
|
SystemError,
|
|
|
|
ApplyError,
|
|
|
|
KeyError,
|
|
|
|
ThrownError,
|
|
|
|
TypeError,
|
|
|
|
ArgError,
|
|
|
|
Overflow,
|
|
|
|
DivisionByZero,
|
2024-09-19 00:52:55 +03:00
|
|
|
OutOfBounds,
|
|
|
|
|
|
|
|
OutOfMemory,
|
|
|
|
|
|
|
|
InvalidCharacter,
|
|
|
|
|
|
|
|
DiskQuota,
|
|
|
|
FileTooBig,
|
|
|
|
InputOutput,
|
|
|
|
NoSpaceLeft,
|
|
|
|
DeviceBusy,
|
|
|
|
InvalidArgument,
|
|
|
|
AccessDenied,
|
|
|
|
BrokenPipe,
|
|
|
|
SystemResources,
|
|
|
|
OperationAborted,
|
|
|
|
NotOpenForWriting,
|
|
|
|
LockViolation,
|
|
|
|
WouldBlock,
|
|
|
|
ConnectionResetByPeer,
|
|
|
|
Unexpected,
|
|
|
|
|
|
|
|
InvalidUtf8,
|
|
|
|
SharingViolation,
|
|
|
|
PathAlreadyExists,
|
|
|
|
FileNotFound,
|
|
|
|
PipeBusy,
|
|
|
|
NameTooLong,
|
|
|
|
InvalidWtf8,
|
|
|
|
BadPathName,
|
|
|
|
NetworkNotFound,
|
|
|
|
AntivirusInterference,
|
|
|
|
SymLinkLoop,
|
|
|
|
ProcessFdQuotaExceeded,
|
|
|
|
SystemFdQuotaExceeded,
|
|
|
|
NoDevice,
|
|
|
|
IsDir,
|
|
|
|
NotDir,
|
|
|
|
FileLocksNotSupported,
|
|
|
|
FileBusy,
|
|
|
|
Unseekable,
|
|
|
|
ConnectionTimedOut,
|
|
|
|
NotOpenForReading,
|
|
|
|
SocketNotConnected,
|
2019-12-08 23:07:41 +03:00
|
|
|
};
|
|
|
|
|
2024-09-19 00:52:55 +03:00
|
|
|
var error_data: ?*MalType = null;
|
|
|
|
|
|
|
|
pub fn throw(mal: *MalType) MalError {
|
|
|
|
assert(error_data == null);
|
|
|
|
error_data = mal;
|
|
|
|
mal.incref();
|
|
|
|
return MalError.ThrownError;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_error_data() ?*MalType {
|
|
|
|
defer error_data = null;
|
|
|
|
return error_data;
|
2019-12-08 23:07:41 +03:00
|
|
|
}
|