Skip to main content

Module error

Module error 

Source
Expand description

Error handling infrastructure for GoudEngine.

This is the canonical Foundation layer location for error types. libs/error/ re-exports from here so both import paths work identically.

§Error Code Ranges

Error codes are organized into ranges by category:

RangeCategoryDescription
0SuccessOperation completed successfully
1-99ContextInitialization and context errors
100-199ResourceAsset and resource management errors
200-299GraphicsRendering and GPU errors
300-399EntityECS entity and component errors
400-499InputInput handling errors
500-599SystemPlatform and system errors
600-699ProviderProvider subsystem errors
900-999InternalUnexpected internal errors

§FFI Compatibility

Error codes use i32 for maximum C ABI compatibility. Negative values are reserved for future use (e.g., platform-specific errors).

Re-exports§

pub use context::GoudErrorContext;
pub use recovery::is_fatal;
pub use recovery::is_recoverable;
pub use recovery::recovery_class;
pub use recovery::recovery_hint;
pub use recovery::RecoveryClass;

Modules§

context
Error context propagation for GoudEngine.
recovery
Error recovery classification for GoudEngine error codes.

Structs§

GoudFFIResult
FFI-safe result type for returning success/failure status across the FFI boundary.

Enums§

GoudError
The main error type for GoudEngine.

Constants§

CONTEXT_ERROR_BASE
Base code for context/initialization errors.
ENTITY_ERROR_BASE
Base code for ECS entity errors.
ERR_ALREADY_INITIALIZED
Engine has already been initialized. Recovery: shut down the engine before re-initializing.
ERR_AUDIO_INIT_FAILED
Audio system initialization failed. Recovery: check that an audio output device is available.
ERR_BACKEND_NOT_SUPPORTED
Graphics backend not supported on this platform. Recovery: update GPU drivers or select a different supported backend.
ERR_BUFFER_CREATION_FAILED
Buffer creation failed. Recovery: reduce buffer size or free unused GPU buffers.
ERR_COMPONENT_ALREADY_EXISTS
Component already exists on entity. Recovery: use replace/update instead of add, or remove the existing component first.
ERR_COMPONENT_NOT_FOUND
Component was not found on entity. Recovery: attach the component before accessing it, or check with a has-component query.
ERR_CONTEXT_DESTROYED
Engine context has been destroyed. Recovery: re-initialize the engine to obtain a new context.
ERR_DRAW_CALL_FAILED
Draw call failed. Recovery: verify buffer bindings and shader state; try updating GPU drivers.
ERR_ENTITY_ALREADY_EXISTS
Entity already exists. Recovery: use a different entity ID or remove the existing entity first.
ERR_ENTITY_NOT_FOUND
Entity was not found. Recovery: verify the entity ID is valid and has not been despawned.
ERR_HANDLE_EXPIRED
Handle refers to a resource that has been deallocated. Recovery: re-create the resource to get a new handle.
ERR_HANDLE_TYPE_MISMATCH
Handle type does not match expected resource type. Recovery: pass the correct handle type for the operation.
ERR_INITIALIZATION_FAILED
Engine initialization failed (generic). Specific error message available via last_error_message(). Recovery: check the error message for details and verify dependencies.
ERR_INPUT_DEVICE_NOT_FOUND
Input device not found or disconnected. Recovery: verify the input device is connected and recognized by the OS.
ERR_INTERNAL_ERROR
Internal engine error (unexpected state). Recovery: report the error with full details; this is likely an engine bug.
ERR_INVALID_CONTEXT
Invalid engine context. Recovery: ensure the context was properly created and not corrupted.
ERR_INVALID_HANDLE
Handle is invalid (null or malformed). Recovery: ensure the handle was obtained from a valid creation call.
ERR_INVALID_INPUT_ACTION
Invalid input action name. Recovery: check the action name matches a registered input action.
ERR_INVALID_STATE
Invalid engine state. Recovery: check the sequence of API calls; the engine may need re-initialization.
ERR_NOT_IMPLEMENTED
Feature not yet implemented. Recovery: use an alternative approach or wait for the feature to be implemented.
ERR_NOT_INITIALIZED
Engine has not been initialized. Recovery: call the initialization function first.
ERR_PHYSICS_INIT_FAILED
Physics system initialization failed. Recovery: review physics configuration for invalid values.
ERR_PLATFORM_ERROR
Generic platform error. Recovery: check the error message for platform-specific details.
ERR_PROVIDER_INIT_FAILED
Provider initialization failed.
ERR_PROVIDER_NOT_FOUND
Provider was not found or not registered.
ERR_PROVIDER_OPERATION_FAILED
Provider operation failed.
ERR_QUERY_FAILED
Query execution failed. Recovery: check for conflicting mutable/immutable access on the same component.
ERR_RENDER_TARGET_FAILED
Render target creation failed. Recovery: verify attachment formats and dimensions are consistent.
ERR_RESOURCE_ALREADY_EXISTS
Resource with this identifier already exists. Recovery: use a unique identifier or remove the existing resource first.
ERR_RESOURCE_INVALID_FORMAT
Resource format is invalid or unsupported. Recovery: verify the file is not corrupted and uses a supported format.
ERR_RESOURCE_LOAD_FAILED
Failed to load resource from source. Recovery: check file permissions and ensure the file is not locked.
ERR_RESOURCE_NOT_FOUND
Requested resource was not found. Recovery: verify the file path and check the working directory.
ERR_SHADER_COMPILATION_FAILED
Shader compilation failed. Recovery: review shader source; the error message contains GPU compiler output.
ERR_SHADER_LINK_FAILED
Shader program linking failed. Recovery: verify shader stage inputs/outputs match and uniforms are declared.
ERR_TEXTURE_CREATION_FAILED
Texture creation failed. Recovery: check texture dimensions and format; reduce size or free GPU resources.
ERR_WINDOW_CREATION_FAILED
Window creation failed. Recovery: verify display server is running and window parameters are valid.
GRAPHICS_ERROR_BASE
Base code for graphics/rendering errors.
INPUT_ERROR_BASE
Base code for input handling errors.
INTERNAL_ERROR_BASE
Base code for internal/unexpected errors.
PROVIDER_ERROR_BASE
Base code for provider errors.
RESOURCE_ERROR_BASE
Base code for resource/asset errors.
SUCCESS
Operation completed successfully.
SYSTEM_ERROR_BASE
Base code for system/platform errors.

Functions§

clear_last_error
Clears the last error for the current thread.
error_category
Returns the category name for an error code.
get_last_error
Gets the last error from the current thread without clearing it.
is_error
Returns true if the error code indicates an error.
is_success
Returns true if the error code indicates success.
last_error_code
Returns the error code of the last error for the current thread.
last_error_message
Returns the error message of the last error for the current thread.
last_error_operation
Returns the operation from the last error’s context, if set.
last_error_subsystem
Returns the subsystem from the last error’s context, if set.
set_last_error
Sets the last error for the current thread.
set_last_error_with_context
Sets the last error and its context for the current thread.
take_last_error
Takes the last error from the current thread, clearing it.

Type Aliases§

GoudErrorCode
FFI-compatible error code type.
GoudResult
A specialized Result type for GoudEngine operations.