1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-26 22:28:26 +03:00
mal/impls/zig/error.zig

72 lines
1.3 KiB
Zig
Raw Permalink Normal View History

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,
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
};
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
}