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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use { libflo_func, libflo_module, serde_json };

error_chain! {
    types { }

    links {
        LibfloFuncError(libflo_func::Error, libflo_func::ErrorKind);
        LibfloModuleError(libflo_module::Error, libflo_module::ErrorKind);
    }

    foreign_links {
        SerdeJsonError(serde_json::Error);
    }

    errors {
        EventConversionFailure(from: String, to: String) {
            description("Error converting general function to specific function.")
            display(
                "{}{}{}{}{}",
                "Error converting general function to specific function. Attempted to convert function of type, '",
                from,
                "', into function of type, '",
                to,
                "'.",
            )
        }

        EventDeserializationFailure(event_text: String) {
            description("Error deserializing event text.")
            display(
                "{}{}",
                "Error deserializing event text:\n",
                event_text,
            )
        }

        EventHandlerDeserializationFailure(event_handler_text: String) {
            description("Error deserializing event handler text. The event handler text could not be deserialized.")
            display(
                "{}{}",
                "Error deserializing event handler text:\n",
                event_handler_text,
            )
        }

        EventLoadNameCollision(event_name: String, module_name: String) {
            description("Error loading event. An event with the same name has already been loaded from the module.")
            display(
                "{}{}{}{}{}",
                "Error loading event with name, '",
                event_name,
                "', from module, '",
                module_name,
                "'. A event with the same name has already been loaded from the module.",
            )
        }

        EventNotFoundInList(event_id: usize, event_list_max: usize) {
            description("Error locating event in event list. The event could not be found.")
            display(
                "{}{}{}{}{}",
                "Error locating event with id, '",
                event_id,
                "', in event list. The event could not be found. The list contains only, '",
                event_list_max,
                "', funcs.",
            )
        }

        EventNotFoundInMap(module_id: usize, event_name: String) {
            description("Error getting event in event map. The event could not be found.")
            display(
                "{}{}{}{}{}",
                "Error locating event with name, '",
                event_name,
                "', for module with id, '",
                module_id,
                "', in event map. The event could not be found.",
            )
        }

        FailureFindingEventHandler(module: usize, event: String) {
            description("Error adding an event handler to an event. The event handler could not be found.")
            display(
                "{}{}{}{}{}",
                "Error adding a function from module, '",
                module,
                ", to the event,",
                event,
                ". The event handler could not be found.",
            )
        }
    }
}