Indentations break the feed.
[SquirrelJME.git] / nanocoat / include / sjme / error.h
blob089443f1a6e463f09127b69b7f9a5dd3788b9a82
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Error codes.
13 * @since 2024/08/09
16 #ifndef SQUIRRELJME_ERROR_H
17 #define SQUIRRELJME_ERROR_H
19 #include "sjme/stdTypes.h"
21 /* Anti-C++. */
22 #ifdef __cplusplus
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_ERROR_H
26 extern "C"
28 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
29 #endif /* #ifdef __cplusplus */
31 /*--------------------------------------------------------------------------*/
33 /**
34 * Error codes.
36 * @since 2023/11/14
38 typedef enum sjme_errorCode
40 /** No error. */
41 SJME_ERROR_NONE = 1,
43 /** Generic unknown error. */
44 SJME_ERROR_UNKNOWN = 0,
46 /** Generic unknown error. */
47 SJME_ERROR_UNKNOWN_NEGATIVE = -1,
49 /** Null arguments. */
50 SJME_ERROR_NULL_ARGUMENTS = -2,
52 /** Local variable out of bounds. */
53 SJME_ERROR_LOCAL_INDEX_INVALID = -3,
55 /** Stack variable out of bounds. */
56 SJME_ERROR_STACK_INDEX_INVALID = -4,
58 /** Stack underflow. */
59 SJME_ERROR_STACK_UNDERFLOW = -5,
61 /** Stack overflow. */
62 SJME_ERROR_STACK_OVERFLOW = -6,
64 /** Top is not an integer type. */
65 SJME_ERROR_TOP_NOT_INTEGER = -7,
67 /** Top is not a long type. */
68 SJME_ERROR_TOP_NOT_LONG = -8,
70 /** Top is not a float type. */
71 SJME_ERROR_TOP_NOT_FLOAT = -9,
73 /** Top is not a double type. */
74 SJME_ERROR_TOP_NOT_DOUBLE = -10,
76 /** Top is not a object type. */
77 SJME_ERROR_TOP_NOT_OBJECT = -11,
79 /** Frame is missing stack treads. */
80 SJME_ERROR_FRAME_MISSING_STACK_TREADS = -12,
82 /** Invalid read of stack. */
83 SJME_ERROR_STACK_INVALID_READ = -13,
85 /** Invalid write of stack. */
86 SJME_ERROR_STACK_INVALID_WRITE = -14,
88 /** Invalid read of stack. */
89 SJME_ERROR_LOCAL_INVALID_READ = -15,
91 /** Invalid write of stack. */
92 SJME_ERROR_LOCAL_INVALID_WRITE = -16,
94 /** Invalid reference pop. */
95 SJME_ERROR_INVALID_REFERENCE_POP = -17,
97 /** Invalid reference push. */
98 SJME_ERROR_INVALID_REFERENCE_PUSH = -18,
100 /** Failed to garbage collect object. */
101 SJME_ERROR_COULD_NOT_GC_OBJECT = -19,
103 /** Object reference count is not zero. */
104 SJME_ERROR_OBJECT_REFCOUNT_NOT_ZERO = -20,
106 /** Garbage collection of object cancelled. */
107 SJME_ERROR_OBJECT_GC_CANCELLED = -21,
109 /** Out of memory. */
110 SJME_ERROR_OUT_OF_MEMORY = -22,
112 /** Pool initialization failed. */
113 SJME_ERROR_POOL_INIT_FAILED = -23,
115 /** Invalid argument. */
116 SJME_ERROR_INVALID_ARGUMENT = -24,
118 /** Not implemented. */
119 SJME_ERROR_NOT_IMPLEMENTED = -25,
121 /** Invalid tread read. */
122 SJME_ERROR_TREAD_INVALID_READ = -26,
124 /** Invalid tread write. */
125 SJME_ERROR_TREAD_INVALID_WRITE = -27,
127 /** There are no suites available. */
128 SJME_ERROR_NO_SUITES = -28,
130 /** Classpath cannot be obtained by both ID and Name. */
131 SJME_ERROR_CLASS_PATH_BY_BOTH = -29,
133 /** Illegal state. */
134 SJME_ERROR_ILLEGAL_STATE = -30,
136 /** A library was not found. */
137 SJME_ERROR_LIBRARY_NOT_FOUND = -31,
139 /** Boot failure. */
140 SJME_ERROR_BOOT_FAILURE = -32,
142 /** Generic JNI exception. */
143 SJME_ERROR_JNI_EXCEPTION = -33,
145 /** Memory has been corrupted. */
146 SJME_ERROR_MEMORY_CORRUPTION = -34,
148 /** Index out of bounds. */
149 SJME_ERROR_INDEX_OUT_OF_BOUNDS = -35,
151 /** Unsupported operation. */
152 SJME_ERROR_UNSUPPORTED_OPERATION = -36,
154 /** Resource not found. */
155 SJME_ERROR_RESOURCE_NOT_FOUND = -37,
157 /** Unexpected end of file. */
158 SJME_ERROR_UNEXPECTED_EOF = -38,
160 /** Invalid identifier. */
161 SJME_ERROR_INVALID_IDENTIFIER = -39,
163 /** Invalid binary name. */
164 SJME_ERROR_INVALID_BINARY_NAME = -40,
166 /** Invalid field type. */
167 SJME_ERROR_INVALID_FIELD_TYPE = -41,
169 /** Invalid method type. */
170 SJME_ERROR_INVALID_METHOD_TYPE = -42,
172 /** Invalid class name. */
173 SJME_ERROR_INVALID_CLASS_NAME = -43,
175 /** Could not load library. */
176 SJME_ERROR_COULD_NOT_LOAD_LIBRARY = -44,
178 /** Invalid library symbol. */
179 SJME_ERROR_INVALID_LIBRARY_SYMBOL = -45,
181 /** There is no graphics display. */
182 SJME_ERROR_HEADLESS_DISPLAY = -46,
184 /** Cannot create something. */
185 SJME_ERROR_CANNOT_CREATE = -47,
187 /** Invalid thread state. */
188 SJME_ERROR_INVALID_THREAD_STATE = -48,
190 /** Component is already in a container. */
191 SJME_ERROR_ALREADY_IN_CONTAINER = -49,
193 /** Not a sub component. */
194 SJME_ERROR_NOT_SUB_COMPONENT = -50,
196 /** No such class exists. */
197 SJME_ERROR_NO_CLASS = -51,
199 /** No such method exists. */
200 SJME_ERROR_NO_METHOD = -52,
202 /** There is no listener. */
203 SJME_ERROR_NO_LISTENER = -53,
205 /** Cancel close of window. */
206 SJME_ERROR_CANCEL_WINDOW_CLOSE = -54,
208 /** The class cannot be casted. */
209 SJME_ERROR_CLASS_CAST = -55,
211 /** The font is not valid. */
212 SJME_ERROR_INVALID_FONT = -56,
214 /** There is no Java environment. */
215 SJME_ERROR_NO_JAVA_ENVIRONMENT = -57,
217 /** Font has negative height. */
218 SJME_ERROR_FONT_NEGATIVE_HEIGHT = -58,
220 /** Could not create native widget. */
221 SJME_ERROR_NATIVE_WIDGET_CREATE_FAILED = -59,
223 /** Clock failure. */
224 SJME_ERROR_NATIVE_SYSTEM_CLOCK_FAILURE = -60,
226 /** A weak reference it attached. */
227 SJME_ERROR_WEAK_REFERENCE_ATTACHED = -61,
229 /** An enqueue has already been set for the weak reference. */
230 SJME_ERROR_ENQUEUE_ALREADY_SET = -62,
232 /** Native error. */
233 SJME_ERROR_NATIVE_ERROR = -63,
235 /** Not a weak reference. */
236 SJME_ERROR_NOT_WEAK_REFERENCE = -64,
238 /** Could not access array natively. */
239 SJME_ERROR_NATIVE_ARRAY_ACCESS_FAILED = -65,
241 /** The graphics buffer is not locked. */
242 SJME_ERROR_BUFFER_NOT_LOCKED = -66,
244 /** Component is not in this container. */
245 SJME_ERROR_NOT_IN_CONTAINER = -67,
247 /** Invalid link. */
248 SJME_ERROR_INVALID_LINK = -68,
250 /** We are not the owner of the lock. */
251 SJME_ERROR_NOT_LOCK_OWNER = -69,
253 /** Item already has a parent. */
254 SJME_ERROR_HAS_PARENT = -70,
256 /** Member already exists. */
257 SJME_ERROR_MEMBER_EXISTS = -71,
259 /** The native widget system failed for some reason. */
260 SJME_ERROR_NATIVE_WIDGET_FAILURE = -72,
262 /** Scan out of bounds. */
263 SJME_ERROR_SCAN_OUT_OF_BOUNDS = -73,
265 /** Native graphics access not yet valid. */
266 SJME_ERROR_FRAMEBUFFER_NOT_READY = -74,
268 /** Could not unload native library. */
269 SJME_ERROR_COULD_NOT_UNLOAD_LIBRARY = -75,
271 /** Could not enqueue onto the message loop. */
272 SJME_ERROR_LOOP_ENQUEUE_FAILED = -76,
274 /** Use fallback. */
275 SJME_ERROR_USE_FALLBACK = -77,
277 /** Continue operation. */
278 SJME_ERROR_CONTINUE = -78,
280 /** Interrupted. */
281 SJME_ERROR_INTERRUPTED = -79,
283 /** Exit. */
284 SJME_ERROR_EXIT = -80,
286 /** Input/Output Exception. */
287 SJME_ERROR_IO_EXCEPTION = -81,
289 /** No such element exists. */
290 SJME_ERROR_NO_SUCH_ELEMENT = -82,
292 /** Path too long. */
293 SJME_ERROR_PATH_TOO_LONG = -83,
295 /** File not found. */
296 SJME_ERROR_FILE_NOT_FOUND = -84,
298 /** Input is too short. */
299 SJME_ERROR_TOO_SHORT = -85,
301 /** Not a Zip. */
302 SJME_ERROR_NOT_ZIP = -86,
304 /** Access it not aligned. */
305 SJME_ERROR_UNALIGNED_ACCESS = -87,
307 /** Zip is corrupt. */
308 SJME_ERROR_CORRUPT_ZIP = -88,
310 /** Unsupported Zip format. */
311 SJME_ERROR_UNSUPPORTED_ZIP_FORMAT = -89,
313 /** Path is a directory. */
314 SJME_ERROR_IS_DIRECTORY = -90,
316 /** Invalid literal length values in inflate. */
317 SJME_ERROR_INFLATE_INVALID_INVERT = -91,
319 /** Invalid block type in inflate stream. */
320 SJME_ERROR_INFLATE_INVALID_BTYPE = -92,
322 /** Invalid dynamic tree length in inflate stream. */
323 SJME_ERROR_INFLATE_INVALID_TREE_LENGTH = -93,
325 /** The code length is invalid. */
326 SJME_ERROR_INFLATE_INVALID_CODE_LENGTH = -94,
328 /** Huffman tree is full. */
329 SJME_ERROR_TRAVERSE_FULL = -95,
331 /** There is a collision in the huffman tree, which means bad data! */
332 SJME_ERROR_TREE_COLLISION = -96,
334 /** The buffer is full. */
335 SJME_ERROR_BUFFER_FULL = -97,
337 /** Huffman tree is incomplete. */
338 SJME_ERROR_INFLATE_HUFF_TREE_INCOMPLETE = -98,
340 /** Tree value has invalid code. */
341 SJME_ERROR_INFLATE_INVALID_CODE = -99,
343 /** Stop operation. */
344 SJME_ERROR_STOP = -100,
346 /** Buffer is saturated. */
347 SJME_ERROR_BUFFER_SATURATED = -101,
349 /** Window distance out of range. */
350 SJME_ERROR_INFLATE_DISTANCE_OUT_OF_RANGE = -102,
352 /** Invalid code length count. */
353 SJME_ERROR_INFLATE_INVALID_CODE_LENGTH_COUNT = -103,
355 /** Invalid repeat of first entry. */
356 SJME_ERROR_INFLATE_INVALID_FIRST_REPEAT = -104,
358 /** Inflation index overflow. */
359 SJME_ERROR_INFLATE_INDEX_OVERFLOW = -105,
361 /** End of file reached. */
362 SJME_ERROR_END_OF_FILE = -106,
364 /** Element already exists. */
365 SJME_ERROR_ELEMENT_EXISTS = -107,
367 /** Capacity exceeded? */
368 SJME_ERROR_CAPACITY_EXCEEDED = -108,
370 /** Tree traversal is too deep. */
371 SJME_ERROR_TREE_TOO_DEEP = -109,
373 /** Invalid class magic number. */
374 SJME_ERROR_INVALID_CLASS_MAGIC = -110,
376 /** Invalid class version. */
377 SJME_ERROR_INVALID_CLASS_VERSION = -111,
379 /** Invalid class pool count. */
380 SJME_ERROR_INVALID_CLASS_POOL_COUNT = -112,
382 /** Invalid class pool index reference. */
383 SJME_ERROR_INVALID_CLASS_POOL_INDEX = -113,
385 /** Reference to class pool index is the wrong type. */
386 SJME_ERROR_WRONG_CLASS_POOL_INDEX_TYPE = -114,
388 /** Class flags are invalid. */
389 SJME_ERROR_INVALID_CLASS_FLAGS = -115,
391 /** Method flags are invalid. */
392 SJME_ERROR_INVALID_METHOD_FLAGS = -116,
394 /** Method has multiple code attributes. */
395 SJME_ERROR_METHOD_MULTIPLE_CODE = -117,
397 /** Invalid field flags. */
398 SJME_ERROR_INVALID_FIELD_FLAGS = -118,
400 /** The number of error codes. */
401 SJME_NUM_ERROR_CODES = -119,
402 } sjme_errorCode;
405 * Propagates an error code which allows others to run accordingly.
407 * @param error The current error code.
408 * @param expression The result from the expression.
409 * @return If @c expression is an error, that will be returned otherwise
410 * the value in @c error provided @c error is not an error.
411 * @since 2024/01/18
413 sjme_errorCode sjme_error_also(
414 sjme_errorCode error, sjme_errorCode expression);
417 * Similar to @c sjme_error_also except this allows multiple error expressions
418 * to be passed until the final is done via @c sjme_error_alsoVEnd() .
420 * @param error The current error state.
421 * @param ... All of the expressions, ends on @c sjme_error_alsoVEnd() .
422 * @return The resultant error code.
423 * @since 2024/01/18
425 sjme_errorCode sjme_error_alsoV(
426 sjme_errorCode error, ...);
429 * The end expression for @c sjme_error_alsoV() .
431 * @return The ending sequence for error codes.
432 * @since 2024/01/18
434 sjme_errorCode sjme_error_alsoVEnd(void);
437 * Is this expression considered an error?
439 * @param error The expression.
440 * @since 2023/12/08
442 sjme_jboolean sjme_error_is(
443 sjme_errorCode error);
446 * Determines the default error code to use.
448 * @param error The error code.
449 * @return Either @c error or a default error.
450 * @since 2023/12/29
452 sjme_errorCode sjme_error_default(
453 sjme_errorCode error);
456 * Determines the default error code to use.
458 * @param error The error code.
459 * @param otherwise The other error code rather than @c SJME_ERROR_UNKNOWN.
460 * @return Either @c error or @c otherwise if the former is not valid.
461 * @since 2023/12/29
463 sjme_errorCode sjme_error_defaultOr(
464 sjme_errorCode error, sjme_errorCode otherwise);
466 /*--------------------------------------------------------------------------*/
468 /* Anti-C++. */
469 #ifdef __cplusplus
470 #ifdef SJME_CXX_SQUIRRELJME_ERROR_H
472 #undef SJME_CXX_SQUIRRELJME_ERROR_H
473 #undef SJME_CXX_IS_EXTERNED
474 #endif /* #ifdef SJME_CXX_SQUIRRELJME_ERROR_H */
475 #endif /* #ifdef __cplusplus */
477 #endif /* SQUIRRELJME_ERROR_H */