Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-julialib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-julialib
Commits
cdb670c0
Commit
cdb670c0
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Introduce abstract CaosDB exception type
parent
f4041bad
No related branches found
No related tags found
1 merge request
!4
ENH: Add minimal functionality
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/CaosDB.jl
+8
-3
8 additions, 3 deletions
src/CaosDB.jl
test/runtests.jl
+1
-0
1 addition, 0 deletions
test/runtests.jl
with
9 additions
and
3 deletions
src/CaosDB.jl
+
8
−
3
View file @
cdb670c0
...
@@ -34,12 +34,17 @@ export evaluate_return_code, CaosDBException
...
@@ -34,12 +34,17 @@ export evaluate_return_code, CaosDBException
using
CaosDB
using
CaosDB
"""
The parent type of all CaosDB errors that can also be used for testing.
"""
abstract type
CaosDBException
<:
Exception
end
"""
"""
A generic exception that will be raised in case of non-zero return
A generic exception that will be raised in case of non-zero return
values of the calls to libccaosdb. May carry a message string and a
values of the calls to libccaosdb. May carry a message string and a
code.
code.
"""
"""
struct
CaosDBException
<:
Exception
struct
Generic
CaosDBException
<:
CaosDB
Exception
msg
::
String
msg
::
String
code
::
Cint
code
::
Cint
end
end
...
@@ -50,7 +55,7 @@ Base.showerror(io::IO, e::CaosDBException) = print(io, "CaosDBException: ", e.ms
...
@@ -50,7 +55,7 @@ Base.showerror(io::IO, e::CaosDBException) = print(io, "CaosDBException: ", e.ms
function evaluate_return_code(code::Cint)
function evaluate_return_code(code::Cint)
Evaluate the return code of a libccaosdb ccall and raise a
Evaluate the return code of a libccaosdb ccall and raise a
`CaosDBException` in case of a non-zero return code.
`
Generic
CaosDBException` in case of a non-zero return code.
"""
"""
function
evaluate_return_code
(
code
::
Cint
)
function
evaluate_return_code
(
code
::
Cint
)
if
code
!=
0
if
code
!=
0
...
@@ -60,7 +65,7 @@ function evaluate_return_code(code::Cint)
...
@@ -60,7 +65,7 @@ function evaluate_return_code(code::Cint)
(
Cint
,),
(
Cint
,),
code
code
)
)
throw
(
CaosDBException
(
unsafe_string
(
msg
),
code
))
throw
(
Generic
CaosDBException
(
unsafe_string
(
msg
),
code
))
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
1
−
0
View file @
cdb670c0
...
@@ -36,5 +36,6 @@ using CaosDB
...
@@ -36,5 +36,6 @@ using CaosDB
@testset
"TestExceptions"
begin
@testset
"TestExceptions"
begin
@test
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
0
))
==
nothing
@test
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
0
))
==
nothing
@test_throws
CaosDB
.
Exceptions
.
CaosDBException
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
14
))
@test_throws
CaosDB
.
Exceptions
.
CaosDBException
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
14
))
@test_throws
CaosDB
.
Exceptions
.
GenericCaosDBException
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
14
))
end
end
end
end
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