From cdb670c091e7627e3f230f771818faff2b563d2f Mon Sep 17 00:00:00 2001
From: florian <f.spreckelsen@inidscale.com>
Date: Thu, 29 Jul 2021 16:07:43 +0200
Subject: [PATCH] ENH: Introduce abstract CaosDB exception type

---
 src/CaosDB.jl    | 11 ++++++++---
 test/runtests.jl |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/CaosDB.jl b/src/CaosDB.jl
index fd94897..e67b91b 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 6190c00..fadbe26 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
-- 
GitLab