impl Display and impl Error for various errors

This commit is contained in:
b-guild
2025-10-23 11:10:48 -07:00
parent 18f4633e26
commit deca3f7ad7
14 changed files with 207 additions and 31 deletions
+2
View File
@@ -35,6 +35,8 @@ pub enum EngineError {
Custom(String),
}
impl std::error::Error for EngineError {}
impl Display for EngineError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
+2
View File
@@ -69,6 +69,8 @@ pub enum FbxError {
FileLoadError(FileError),
}
impl std::error::Error for FbxError {}
impl Display for FbxError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
+35
View File
@@ -20,6 +20,8 @@
//! Skybox is a huge box around a camera. See [`SkyBox`] docs for more info.
use std::fmt::Display;
use crate::{
asset::{builtin::BuiltInResource, embedded_data_source, untyped::ResourceKind},
core::{log::Log, reflect::prelude::*, uuid_provider, visitor::prelude::*},
@@ -377,6 +379,39 @@ pub enum SkyBoxError {
},
}
impl std::error::Error for SkyBoxError {}
impl Display for SkyBoxError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SkyBoxError::UnsupportedTextureKind(texture_kind) => {
write!(f, "Unsupported texture kind: {texture_kind:?}")
}
SkyBoxError::UnableToBuildCubeMap => f.write_str("Cube map was failed to build."),
SkyBoxError::NonSquareTexture {
index,
width,
height,
} => write!(
f,
"Input texture is not square. Index: {index}, width: {width}, height: {height}"
),
SkyBoxError::DifferentTexture {
expected_width,
expected_height,
expected_pixel_kind,
index,
actual_width,
actual_height,
actual_pixel_kind,
} => write!(f, "Some input texture differs in size or pixel kind. Index: {index}. \
Expected width: {expected_width}, height: {expected_height}, kind: {expected_pixel_kind:?}. \
Actual width: {actual_width}, height: {actual_height}, kind: {actual_pixel_kind:?}."),
SkyBoxError::TextureIsNotReady { index } => write!(f, "Input texture is not loaded. Index: {index}"),
}
}
}
/// SkyBox builder is used to create new skybox in declarative manner.
pub struct SkyBoxBuilder {
/// Texture for front face.
+2
View File
@@ -309,6 +309,8 @@ pub enum LightmapGenerationError {
InvalidData(VertexFetchError),
}
impl std::error::Error for LightmapGenerationError {}
impl Display for LightmapGenerationError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {