Skip to content

Commit dd48d7e

Browse files
committed
More errors
1 parent 5d92de9 commit dd48d7e

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

src/errors.jl

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,55 @@
11
"""
2-
DFGLabelError(label)
2+
DFGLabelNotFoundError(label, available)
33
4-
Label not found.
4+
Error thrown when a requested label is not found in the factor graph.
5+
6+
# Arguments
7+
- `label`: The label that was not found.
8+
- `available`: The list of available labels.
59
"""
6-
struct DFGLabelError <: Exception
10+
struct DFGLabelNotFoundError <: Exception
711
label::Any
812
available::Any
913
end
1014

11-
DFGLabelError(key::T) where {T} = DFGLabelError(key, T[])
15+
DFGLabelNotFoundError(label::T) where {T} = DFGLabelNotFoundError(label, T[])
1216

13-
function Base.showerror(io::IO, ex::DFGLabelError)
14-
print(io, "DFGLabelError: label ", ex.label, " not found.")
17+
function Base.showerror(io::IO, ex::DFGLabelNotFoundError)
18+
print(io, "DFGLabelNotFoundError: label ", ex.label, " not found.")
1519
if !isempty(ex.available)
1620
println(io, " Available labels:")
1721
show(io, ex.available)
1822
end
1923
end
24+
25+
"""
26+
DFGLabelExistsError(label)
27+
28+
Error thrown when attempting to add a label that already exists in the factor graph.
29+
30+
# Arguments
31+
- `label`: The label that already exists.
32+
"""
33+
struct DFGLabelExistsError <: Exception
34+
label::Any
35+
end
36+
37+
function Base.showerror(io::IO, ex::DFGLabelExistsError)
38+
print(io, "DFGLabelExistsError: label ", ex.label, " already exists in the factor graph.")
39+
end
40+
41+
"""
42+
DFGSerializationError(msg)
43+
44+
Error thrown when serialization or deserialization fails.
45+
46+
# Arguments
47+
- `msg`: Description of the serialization error.
48+
"""
49+
struct DFGSerializationError <: Exception
50+
msg::String
51+
end
52+
53+
function Base.showerror(io::IO, ex::DFGSerializationError)
54+
print(io, "DFGSerializationError: ", ex.msg)
55+
end

0 commit comments

Comments
 (0)