diff --git a/src/CaosDB.jl b/src/CaosDB.jl index fd94897c82f1161bbcbbb878a5dea3b6994b75b9..e67b91bd1a02fe02bdd05cebd3ad961f742344fa 100644 --- a/src/CaosDB.jl +++ b/src/CaosDB.jl @@ -34,12 +34,17 @@ export evaluate_return_code, CaosDBException 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 values of the calls to libccaosdb. May carry a message string and a code. """ -struct CaosDBException <: Exception +struct GenericCaosDBException <: CaosDBException msg::String code::Cint end @@ -50,7 +55,7 @@ Base.showerror(io::IO, e::CaosDBException) = print(io, "CaosDBException: ", e.ms function evaluate_return_code(code::Cint) Evaluate the return code of a libccaosdb ccall and raise a -`CaosDBException` in case of a non-zero return code. +`GenericCaosDBException` in case of a non-zero return code. """ function evaluate_return_code(code::Cint) if code != 0 @@ -60,7 +65,7 @@ function evaluate_return_code(code::Cint) (Cint,), code ) - throw(CaosDBException(unsafe_string(msg), code)) + throw(GenericCaosDBException(unsafe_string(msg), code)) end end diff --git a/test/runtests.jl b/test/runtests.jl index 6190c003a2d538794ab098ddd9a62e2417ccb3fa..fadbe268cd7b8395031eb98f265f2d3182d2bbfd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -36,5 +36,6 @@ using CaosDB @testset "TestExceptions" begin @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.GenericCaosDBException CaosDB.Exceptions.evaluate_return_code(Cint(14)) end end