Skip to main content

scena/diagnostics/display/
asset.rs

1use std::fmt;
2
3use crate::diagnostics::AssetError;
4
5impl fmt::Display for AssetError {
6    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
7        match self {
8            Self::NotFound { path } => write!(formatter, "asset was not found: {path}"),
9            Self::Io { path, reason } => {
10                write!(formatter, "failed to read asset {path}: {reason}")
11            }
12            Self::PolicyViolation { path, reason, .. } => {
13                write!(formatter, "asset {path} violates policy: {reason}")
14            }
15            Self::Parse { path, reason } => {
16                write!(formatter, "failed to parse asset {path}: {reason}")
17            }
18            Self::UnsupportedRequiredExtension { path, extension } => write!(
19                formatter,
20                "asset {path} requires unsupported extension {extension}"
21            ),
22            Self::UnsupportedOptionalExtensionUsed {
23                path,
24                extension,
25                help,
26            } => write!(
27                formatter,
28                "asset {path} uses unsupported optional extension {extension}: {help}"
29            ),
30            Self::MissingTexture {
31                path,
32                material_slot,
33                texture_index,
34                help,
35            } => write!(
36                formatter,
37                "asset {path} references missing texture index {texture_index} in material slot {material_slot}: {help}"
38            ),
39            Self::UnsupportedTextureFormat { path, help } => write!(
40                formatter,
41                "texture {path} uses an unsupported format: {help}"
42            ),
43            Self::Cancelled { path, help } => {
44                write!(formatter, "asset load for {path} was cancelled: {help}")
45            }
46            Self::UnsupportedEnvironmentFormat { path, help } => write!(
47                formatter,
48                "environment {path} uses an unsupported format: {help}"
49            ),
50            Self::ReloadRequiresRetain { path, help } => {
51                write!(formatter, "asset {path} cannot be reloaded: {help}")
52            }
53            Self::GeometryHandleNotFound { geometry } => {
54                write!(
55                    formatter,
56                    "geometry handle {geometry:?} was not found in Assets"
57                )
58            }
59            Self::MaterialHandleNotFound { material } => {
60                write!(
61                    formatter,
62                    "material handle {material:?} was not found in Assets"
63                )
64            }
65            Self::TextureHandleNotFound { texture } => {
66                write!(
67                    formatter,
68                    "texture handle {texture:?} was not found in Assets"
69                )
70            }
71            Self::EnvironmentHandleNotFound { environment } => write!(
72                formatter,
73                "environment handle {environment:?} was not found in Assets"
74            ),
75        }
76    }
77}