Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OPOSSUM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
phelix
rust
OPOSSUM
Commits
ae6a1730
Commit
ae6a1730
authored
1 year ago
by
Udo Eisenbarth
Browse files
Options
Downloads
Patches
Plain Diff
Improve error handling
parent
d80d9dd7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/error.rs
+5
-1
5 additions, 1 deletion
src/error.rs
src/nodes/node_group.rs
+3
-3
3 additions, 3 deletions
src/nodes/node_group.rs
src/optic_scenery.rs
+3
-3
3 additions, 3 deletions
src/optic_scenery.rs
with
11 additions
and
7 deletions
src/error.rs
+
5
−
1
View file @
ae6a1730
#[derive(Debug,
Clone)]
pub
struct
OpossumError
;
\ No newline at end of file
pub
enum
OpossumError
{
OpticScenery
(
String
),
OpticGroup
(
String
),
Other
(
String
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/nodes/node_group.rs
+
3
−
3
View file @
ae6a1730
...
...
@@ -31,15 +31,15 @@ impl NodeGroup {
target_node
:
NodeIndex
,
)
->
Result
<
EdgeIndex
>
{
if
self
.g
.node_weight
(
src_node
)
.is_none
()
{
return
Err
(
OpossumError
);
return
Err
(
OpossumError
::
OpticGroup
(
"source node with gievn index does not exist"
.into
())
);
}
if
self
.g
.node_weight
(
target_node
)
.is_none
()
{
return
Err
(
OpossumError
);
return
Err
(
OpossumError
::
OpticGroup
(
"target node with given index does not exist"
.into
())
);
}
let
edge_index
=
self
.g
.add_edge
(
src_node
,
target_node
,
());
if
is_cyclic_directed
(
&
self
.g
)
{
self
.g
.remove_edge
(
edge_index
);
return
Err
(
OpossumError
);
return
Err
(
OpossumError
::
OpticGroup
(
"connecting the given nodes would form a loop"
.into
())
);
}
Ok
(
edge_index
)
}
...
...
This diff is collapsed.
Click to expand it.
src/optic_scenery.rs
+
3
−
3
View file @
ae6a1730
...
...
@@ -45,15 +45,15 @@ impl OpticScenery {
target_node
:
NodeIndex
,
)
->
Result
<
EdgeIndex
>
{
if
self
.g
.node_weight
(
src_node
)
.is_none
()
{
return
Err
(
OpossumError
);
return
Err
(
OpossumError
::
OpticScenery
(
"source node with gievn index does not exist"
.into
())
);
}
if
self
.g
.node_weight
(
target_node
)
.is_none
()
{
return
Err
(
OpossumError
);
return
Err
(
OpossumError
::
OpticScenery
(
"target node with given index does not exist"
.into
())
);
}
let
edge_index
=
self
.g
.add_edge
(
src_node
,
target_node
,
());
if
is_cyclic_directed
(
&
self
.g
)
{
self
.g
.remove_edge
(
edge_index
);
return
Err
(
OpossumError
);
return
Err
(
OpossumError
::
OpticScenery
(
"connecting the given nodes would form a loop"
.into
())
);
}
Ok
(
edge_index
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment