Skip to content

Commit 44659cf

Browse files
committed
More errors
1 parent 5d92de9 commit 44659cf

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

src/errors.jl

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,60 @@
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+
return print(
39+
io,
40+
"DFGLabelExistsError: label ",
41+
ex.label,
42+
" already exists in the factor graph.",
43+
)
44+
end
45+
46+
"""
47+
DFGSerializationError(msg)
48+
49+
Error thrown when serialization or deserialization fails.
50+
51+
# Arguments
52+
- `msg`: Description of the serialization error.
53+
"""
54+
struct DFGSerializationError <: Exception
55+
msg::String
56+
end
57+
58+
function Base.showerror(io::IO, ex::DFGSerializationError)
59+
return print(io, "DFGSerializationError: ", ex.msg)
60+
end

0 commit comments

Comments
 (0)