mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
impl Display and impl Error for various errors
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user