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
8c05bf53
Commit
8c05bf53
authored
3 years ago
by
florian
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add logging messages for return codes <0
parent
78f93340
No related branches found
No related tags found
1 merge request
!4
ENH: Add minimal functionality
Pipeline
#10970
passed
3 years ago
Stage: info
Stage: code-style
Stage: setup
Stage: test
Stage: deploy
Pipeline: CaosDB Julia Integration Tests
#10971
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/CaosDB.jl
+21
-4
21 additions, 4 deletions
src/CaosDB.jl
src/Connection.jl
+6
-6
6 additions, 6 deletions
src/Connection.jl
test/runtests.jl
+22
-0
22 additions, 0 deletions
test/runtests.jl
with
49 additions
and
10 deletions
src/CaosDB.jl
+
21
−
4
View file @
8c05bf53
...
@@ -31,8 +31,9 @@ library_name = (@static Sys.iswindows() ? "ccaosdb" : "libccaosdb")
...
@@ -31,8 +31,9 @@ library_name = (@static Sys.iswindows() ? "ccaosdb" : "libccaosdb")
module
Exceptions
module
Exceptions
export
evaluate_return_code
,
CaosDBException
,
GenericCaosDBException
export
evaluate_return_code
,
CaosDBException
,
GenericCaosDBException
,
CaosDBMessage
using
Logging
using
CaosDB
using
CaosDB
"""
"""
...
@@ -50,7 +51,19 @@ struct GenericCaosDBException <: CaosDBException
...
@@ -50,7 +51,19 @@ struct GenericCaosDBException <: CaosDBException
code
::
Cint
code
::
Cint
end
end
Base
.
showerror
(
io
::
IO
,
e
::
CaosDBException
)
=
print
(
io
,
"CaosDBException: "
,
e
.
msg
)
Base
.
showerror
(
io
::
IO
,
e
::
CaosDBException
)
=
print
(
io
,
"CaosDBException: "
,
e
.
msg
,
" (Status code "
,
e
.
code
,
")"
)
"""
Struct containing Messages and codes for status codes<0 that do not
correspond to errors or success.
"""
struct
CaosDBMessage
msg
::
String
code
::
Cint
end
Base
.
show
(
io
::
IO
,
m
::
CaosDBMessage
)
=
print
(
io
,
m
.
msg
,
" (Status code "
,
m
.
code
,
")"
)
"""
"""
function evaluate_return_code(code::Cint)
function evaluate_return_code(code::Cint)
...
@@ -66,7 +79,11 @@ function evaluate_return_code(code::Cint)
...
@@ -66,7 +79,11 @@ function evaluate_return_code(code::Cint)
(
Cint
,),
(
Cint
,),
code
,
code
,
)
)
throw
(
GenericCaosDBException
(
unsafe_string
(
msg
),
code
))
if
code
>
0
throw
(
GenericCaosDBException
(
unsafe_string
(
msg
),
code
))
else
@info
CaosDBMessage
(
unsafe_string
(
msg
),
code
)
end
end
end
end
end
...
@@ -180,7 +197,7 @@ function create_plain_password_authenticator(
...
@@ -180,7 +197,7 @@ function create_plain_password_authenticator(
password
,
password
,
)
)
CaosDB
.
Excepions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Excep
t
ions
.
evaluate_return_code
(
err_code
)
return
auth
return
auth
...
...
This diff is collapsed.
Click to expand it.
src/Connection.jl
+
6
−
6
View file @
8c05bf53
...
@@ -134,7 +134,7 @@ function create_pem_file_certificate_provider(path::AbstractString)
...
@@ -134,7 +134,7 @@ function create_pem_file_certificate_provider(path::AbstractString)
path
,
path
,
)
)
CaosDB
.
Excepions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Excep
t
ions
.
evaluate_return_code
(
err_code
)
return
cert_provider
return
cert_provider
...
@@ -176,7 +176,7 @@ function create_tls_connection_configuration(
...
@@ -176,7 +176,7 @@ function create_tls_connection_configuration(
provider
,
provider
,
)
)
CaosDB
.
Excepions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Excep
t
ions
.
evaluate_return_code
(
err_code
)
return
config
return
config
...
@@ -195,7 +195,7 @@ function create_insecure_connection_configuration(host::AbstractString, port::Ci
...
@@ -195,7 +195,7 @@ function create_insecure_connection_configuration(host::AbstractString, port::Ci
port
,
port
,
)
)
CaosDB
.
Excepions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Excep
t
ions
.
evaluate_return_code
(
err_code
)
return
config
return
config
end
end
...
@@ -217,7 +217,7 @@ function create_connection(config::Ref{_Configuration})
...
@@ -217,7 +217,7 @@ function create_connection(config::Ref{_Configuration})
config
,
config
,
)
)
CaosDB
.
Excepions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Excep
t
ions
.
evaluate_return_code
(
err_code
)
return
connection
return
connection
...
@@ -248,7 +248,7 @@ function get_connection(name::AbstractString = "default")
...
@@ -248,7 +248,7 @@ function get_connection(name::AbstractString = "default")
)
)
end
end
CaosDB
.
Excepions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Excep
t
ions
.
evaluate_return_code
(
err_code
)
return
connection
return
connection
...
@@ -273,7 +273,7 @@ function get_version_info(con::Ref{_Connection})
...
@@ -273,7 +273,7 @@ function get_version_info(con::Ref{_Connection})
con
,
con
,
)
)
CaosDB
.
Excepions
.
evaluate_return_code
(
err_code
)
CaosDB
.
Excep
t
ions
.
evaluate_return_code
(
err_code
)
return
info
return
info
...
...
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
22
−
0
View file @
8c05bf53
...
@@ -34,12 +34,34 @@ using CaosDB
...
@@ -34,12 +34,34 @@ using CaosDB
end
end
@testset
"TestExceptions"
begin
@testset
"TestExceptions"
begin
# In case of success, nothing is done
@test
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
0
))
==
nothing
@test
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
0
))
==
nothing
# CaosDBExceptions are thrown for return codes > 0
@test_throws
CaosDB
.
Exceptions
.
CaosDBException
CaosDB
.
Exceptions
.
evaluate_return_code
(
@test_throws
CaosDB
.
Exceptions
.
CaosDBException
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
14
),
Cint
(
14
),
)
)
@test_throws
CaosDB
.
Exceptions
.
GenericCaosDBException
CaosDB
.
Exceptions
.
evaluate_return_code
(
@test_throws
CaosDB
.
Exceptions
.
GenericCaosDBException
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
14
),
Cint
(
14
),
)
)
try
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
14
))
# fail if this doesn't throw an error
@test
false
catch
e
@test
isa
(
e
,
CaosDB
.
Exceptions
.
GenericCaosDBException
)
@test
e
.
code
==
14
end
# Return codes < 0 correspond to unfinished transactions and
# we expect messages to be returned.
@test
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
-
1
))
==
nothing
@test_logs
(
:
info
,
CaosDB
.
Exceptions
.
CaosDBMessage
(
"The transaction is currently being executed."
,
Cint
(
-
1
),
),
)
CaosDB
.
Exceptions
.
evaluate_return_code
(
Cint
(
-
1
))
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