1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::{str::Utf8Error, string::FromUtf8Error};

error_chain! {
    foreign_links {
        FromUtf8(FromUtf8Error) #[doc = "Wraps a UTF-8 error"];
        Utf8(Utf8Error) #[doc = "Wraps a UTF-8 error"];
    }

    errors {
        /// Returned if an asset with a given name failed to load.
        Asset(name: String) {
            description("Failed to load asset")
            display("Failed to load asset with name {:?}", name)
        }

        /// Returned if a source could not retrieve something.
        Source {
            description("Failed to load bytes from source")
        }

        /// Returned if a format failed to load the asset data.
        Format(format: &'static str) {
            description("Format could not load asset")
            display("Format {:?} could not load asset", format)
        }

        /// Returned if an asset is loaded and never used.
        UnusedHandle {
            description("Asset was loaded but no handle to it was saved.")
        }
    }
}