module

PointClickEngine::Core::ErrorHelpers

Utility methods for common error handling patterns

Instance methods

ensure_directory_exists(path : String) : Result(String, FileError)

Create directory if it doesn't exist

Source
safe_execute(error_class : E.class, message : String, &block : -> T) : Result(T, E) forall T, E

Safely execute a block that might raise an exception

Source
safe_file_read(path : String) : Result(String, FileError)

Safely read a file

Source
safe_file_write(path : String, content : String) : Result(Nil, FileError)

Safely write to a file

Source
safe_load_music(path : String) : Result(RAudio::Music, AssetError)

Load music with error handling

Source
safe_load_sound(path : String) : Result(RAudio::Sound, AssetError)

Load sound with error handling

Source
safe_load_texture(path : String) : Result(Raylib::Texture2D, AssetError)

Load asset with error handling

Source
validate_directory_exists(path : String) : Result(String, FileError)

Validate that a directory exists

Source
validate_file_exists(path : String) : Result(String, FileError)

Validate that a file exists

Source
validate_not_empty(value : String, field_name : String) : Result(String, ValidationError)

Validate that a string is not empty

Source
validate_not_nil(value : T | Nil, error_message : String) : Result(T, ValidationError) forall T

Validate that a value is not nil

Source
validate_range(value : T, min : T, max : T, field_name : String) : Result(T, ValidationError) forall T

Validate numeric range

Source