-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.jl
More file actions
57 lines (47 loc) · 1.37 KB
/
errors.jl
File metadata and controls
57 lines (47 loc) · 1.37 KB
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
"""
LabelNotFoundError(label, available)
Error thrown when a requested label is not found in the factor graph.
"""
struct LabelNotFoundError <: Exception
name::String
label::Symbol
available::Vector{Symbol}
end
LabelNotFoundError(name::String, label::Symbol) = LabelNotFoundError(name, label, Symbol[])
LabelNotFoundError(label::Symbol) = LabelNotFoundError("Node", label, Symbol[])
function Base.showerror(io::IO, ex::LabelNotFoundError)
print(io, "LabelNotFoundError: ", ex.name, " label '", ex.label, "' not found.")
if !isempty(ex.available)
println(io, " Available labels:")
show(io, ex.available)
end
end
"""
LabelExistsError(label)
Error thrown when attempting to add a label that already exists in the collection.
"""
struct LabelExistsError <: Exception
name::String
label::Symbol
end
LabelExistsError(label::Symbol) = LabelExistsError("Node", label)
function Base.showerror(io::IO, ex::LabelExistsError)
return print(
io,
"LabelExistsError: ",
ex.name,
" label '",
ex.label,
"' already exists.",
)
end
"""
SerializationError(msg)
Error thrown when serialization or deserialization fails.
"""
struct SerializationError <: Exception
msg::String
end
function Base.showerror(io::IO, ex::SerializationError)
return print(io, "SerializationError: ", ex.msg)
end