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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use crate::{
    boss::{folders::FolderGraphError, FileSerializationError},
    Resource, SerializedDataError,
};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use thiserror::Error;

#[derive(Debug, Error, Serialize, Deserialize)]
pub enum StartupError {
    #[error("couldn't deserialize yyp -- {}", .0)]
    BadYypDeserialize(String),

    #[error("couldn't make or find the boss directory -- {}", .0)]
    BossDirectory(String),

    #[error("couldn't deserialize file at {:?} -- {}", .filepath, .error)]
    BadYyFile { filepath: PathBuf, error: String },

    #[error("couldn't load in resource {} in Asset Browser. Could be corrupted -- {}", .name, .error)]
    BadResourceTree { name: String, error: String },

    #[error("bad path for yyp was given -- {:?}, {}", .yyp_filepath, .error)]
    BadYypPath {
        yyp_filepath: PathBuf,
        error: String,
    },

    #[error("a working directory path was given, but it was invalid")]
    BadWorkingDirectoryPath,

    #[error("bad arguments -- {}", .0)]
    BadCliArguments(String),
}

#[derive(Debug, Error)]
pub enum ResourceManipulationError {
    #[error(transparent)]
    FolderGraphError(#[from] FolderGraphError),

    #[error("cannot add that resource -- a {} of that name already exists", .0)]
    NameCollision(Resource),

    #[error("cannot use that name -- resource names must be [A-z_]\\w+")]
    BadName,

    #[error("cannot find that resource")]
    BadGet,

    #[error("internal error -- yyp-boss is in undefined state")]
    InternalError,
}

#[derive(Debug, Error)]
pub enum YyResourceHandlerError {
    #[error(transparent)]
    FileSerializationError(#[from] FileSerializationError),

    #[error(transparent)]
    SerializedDataError(#[from] SerializedDataError),

    #[error("the given resource was not found or managed on the type")]
    ResourceNotFound,

    #[error("we cannot force serialization because the associated data could not be found")]
    CannotForceSerialization,
}