pub struct GaiaError { /* private fields */ }Expand description
Gaia error type, wrapping a specific error kind GaiaErrorKind
Box is used here to reduce the size of the enum and improve performance.
Implementations§
Source§impl GaiaError
impl GaiaError
Sourcepub fn syntax_error(
message: impl ToString,
location: SourceLocation,
) -> GaiaError
pub fn syntax_error( message: impl ToString, location: SourceLocation, ) -> GaiaError
Creates a syntax error
Use this function to create an error when source code parsing encounters a syntax issue.
§Parameters
message- Error message describing the specific syntax issuelocation- Source code location information where the error occurred
§Return Value
Returns a GaiaError instance containing the syntax error information.
§Example
let location = SourceLocation::default();
let error = GaiaError::syntax_error("missing semicolon", location);Sourcepub fn io_error(io_error: Error, url: Url) -> GaiaError
pub fn io_error(io_error: Error, url: Url) -> GaiaError
Creates an IO error
Use this function to create an error when file read/write, network request, or other IO operations fail.
§Parameters
io_error- The underlying IO errorurl- URL associated with the IO operation (such as file path or network address)
§Return Value
Returns a GaiaError instance containing the IO error information.
§Example
use gaia_types::GaiaError;
use url::Url;
let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "file not found");
let url = Url::from_file_path("/path/to/file")
.ok()
.and_then(|x| Some(x))
.unwrap_or_else(|| Url::parse("file:///path/to/file").unwrap());
let error = GaiaError::io_error(io_err, url);Sourcepub fn invalid_instruction(
instruction: impl ToString,
architecture: Architecture,
) -> GaiaError
pub fn invalid_instruction( instruction: impl ToString, architecture: Architecture, ) -> GaiaError
Creates an invalid instruction error
Use this function to create an error when an unknown or unsupported instruction is parsed.
§Parameters
instruction- Invalid instruction stringarchitecture- Architecture to which the instruction belongs
§Return Value
Returns a GaiaError instance containing the invalid instruction error information.
§Example
use gaia_types::{helpers::Architecture, GaiaError};
let error = GaiaError::invalid_instruction("unknown instruction", Architecture::X86);Sourcepub fn unsupported_architecture(architecture: Architecture) -> GaiaError
pub fn unsupported_architecture(architecture: Architecture) -> GaiaError
Creates an unsupported architecture error
Use this function to create an error when attempting to perform an operation on an unsupported architecture.
§Parameters
architecture- Unsupported architecture
§Return Value
Returns a GaiaError instance containing the unsupported architecture error information.
§Example
use gaia_types::{helpers::Architecture, GaiaError};
let error = GaiaError::unsupported_architecture(Architecture::ARM32);Sourcepub fn invalid_range(length: usize, expect: usize) -> GaiaError
pub fn invalid_range(length: usize, expect: usize) -> GaiaError
Creates an invalid range error
Use this function to create an error when the actual data length does not match the expected length.
§Parameters
length- Actual lengthexpect- Expected length
§Return Value
Returns a GaiaError instance containing the invalid range error information.
§Example
use gaia_types::GaiaError;
let error = GaiaError::invalid_range(1024, 2048);Sourcepub fn invalid_data(data: impl ToString) -> GaiaError
pub fn invalid_data(data: impl ToString) -> GaiaError
Sourcepub fn kind(&self) -> &GaiaErrorKind
pub fn kind(&self) -> &GaiaErrorKind
Returns the kind of error.
Sourcepub fn not_implemented(feature: impl ToString) -> GaiaError
pub fn not_implemented(feature: impl ToString) -> GaiaError
Creates a feature not implemented error
Use this function to create an error when a feature that is not yet implemented is called.
§Parameters
feature- Description of the unimplemented feature
§Return Value
Returns a GaiaError instance containing the feature not implemented error information.
§Example
let error = GaiaError::not_implemented("PE context creation");Sourcepub fn adapter_error(
adapter_name: impl ToString,
message: impl ToString,
source: Option<Box<GaiaError>>,
) -> GaiaError
pub fn adapter_error( adapter_name: impl ToString, message: impl ToString, source: Option<Box<GaiaError>>, ) -> GaiaError
Sourcepub fn platform_unsupported(
platform: impl ToString,
operation: impl ToString,
) -> GaiaError
pub fn platform_unsupported( platform: impl ToString, operation: impl ToString, ) -> GaiaError
Sourcepub fn config_error(
config_path: Option<impl ToString>,
message: impl ToString,
) -> GaiaError
pub fn config_error( config_path: Option<impl ToString>, message: impl ToString, ) -> GaiaError
Sourcepub fn unsupported_target(target: CompilationTarget) -> GaiaError
pub fn unsupported_target(target: CompilationTarget) -> GaiaError
Sourcepub fn compilation_failed(
target: CompilationTarget,
message: impl ToString,
) -> GaiaError
pub fn compilation_failed( target: CompilationTarget, message: impl ToString, ) -> GaiaError
Creates a compilation failed error
§Parameters
target- Compilation targetmessage- Error message
§Example
let target = CompilationTarget {
build: Architecture::X86_64,
host: AbiCompatible::ELF,
target: ApiCompatible::Gnu,
};
let error = GaiaError::compilation_failed(target, "failed to generate bytecode");Sourcepub fn save_error(format: impl ToString, message: impl ToString) -> GaiaError
pub fn save_error(format: impl ToString, message: impl ToString) -> GaiaError
Sourcepub fn unsupported_feature(
feature: impl ToString,
location: SourceLocation,
) -> GaiaError
pub fn unsupported_feature( feature: impl ToString, location: SourceLocation, ) -> GaiaError
Sourcepub fn custom_error(message: impl ToString) -> GaiaError
pub fn custom_error(message: impl ToString) -> GaiaError
Sourcepub fn unreachable() -> GaiaError
pub fn unreachable() -> GaiaError
Creates an unreachable error.
Use this function when program execution reaches a theoretically unreachable code path. It automatically captures the caller location.
§Return Value
Returns a GaiaError instance containing the unreachable error information.
§Example
fn example_unreachable() -> Result<(), GaiaError> {
let value = 1;
match value {
1 => Ok(()),
_ => Err(GaiaError::unreachable()), // This is theoretically unreachable
}
}
let _ = example_unreachable();Trait Implementations§
Source§impl Debug for GaiaError
Implements the Debug trait for GaiaError.
impl Debug for GaiaError
Implements the Debug trait for GaiaError.
When outputting in Debug format, it delegates to the internal GaiaErrorKind.
Source§impl Display for GaiaError
Implements the Display trait for GaiaError.
impl Display for GaiaError
Implements the Display trait for GaiaError.
When outputting in Display format, it delegates to the internal GaiaErrorKind.
Source§impl Error for GaiaError
Implements the standard library Error trait for GaiaError.
impl Error for GaiaError
Implements the standard library Error trait for GaiaError.
This allows GaiaError to be used as a standard error type.
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<GaiaErrorKind> for GaiaError
Implementation for converting GaiaErrorKind to GaiaError
impl From<GaiaErrorKind> for GaiaError
Implementation for converting GaiaErrorKind to GaiaError
This conversion automatically wraps the error kind in a Box, as required by the GaiaError struct, reducing memory footprint.