Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/DataBlobs/services/BlobEntry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,14 @@ Also see: [`addBlobentry!`](@ref), [`getBlob`](@ref), [`listBlobentries`](@ref)
"""
function getBlobentry(var::AbstractDFGVariable, key::Symbol)
if !hasBlobentry(var, key)
throw(
KeyError(
"No dataEntry label $(key) found in variable $(getLabel(var)). Available keys: $(keys(var.dataDict))",
),
)
throw(DFGLabelError(key, keys(var.dataDict)))
end
return var.dataDict[key]
end

function getBlobentry(var::VariableDFG, key::Symbol)
if !hasBlobentry(var, key)
throw(KeyError(key))
throw(DFGLabelError(key))
Comment thread
Affie marked this conversation as resolved.
Outdated
end
return var.blobEntries[findfirst(x -> x.label == key, var.blobEntries)]
end
Expand Down
1 change: 1 addition & 0 deletions src/DistributedFactorGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ export plotDFG
##==============================================================================

# Entities
include("errors.jl")

include("entities/AbstractDFG.jl")

Expand Down
60 changes: 60 additions & 0 deletions src/errors.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""
Comment thread
Affie marked this conversation as resolved.
DFGLabelNotFoundError(label, available)

Error thrown when a requested label is not found in the factor graph.

# Arguments
- `label`: The label that was not found.
- `available`: The list of available labels.
"""
struct DFGLabelNotFoundError <: Exception
label::Any
available::Any
end

DFGLabelNotFoundError(label::T) where {T} = DFGLabelNotFoundError(label, T[])

function Base.showerror(io::IO, ex::DFGLabelNotFoundError)
print(io, "DFGLabelNotFoundError: label ", ex.label, " not found.")
if !isempty(ex.available)
println(io, " Available labels:")
show(io, ex.available)
end
end

"""
DFGLabelExistsError(label)

Error thrown when attempting to add a label that already exists in the factor graph.

# Arguments
- `label`: The label that already exists.
"""
struct DFGLabelExistsError <: Exception
label::Any
end

function Base.showerror(io::IO, ex::DFGLabelExistsError)
return print(
io,
"DFGLabelExistsError: label ",
ex.label,
" already exists in the factor graph.",
)
end

"""
DFGSerializationError(msg)

Error thrown when serialization or deserialization fails.

# Arguments
- `msg`: Description of the serialization error.
"""
struct DFGSerializationError <: Exception
msg::String
end

function Base.showerror(io::IO, ex::DFGSerializationError)
return print(io, "DFGSerializationError: ", ex.msg)
end
Comment thread
Affie marked this conversation as resolved.
Outdated
Loading