diff --git a/km3buu/output.py b/km3buu/output.py
index 1526195d76761f8bdf940947d724afe46f7a98f3..5d89d83922c00290e0240cdc550e5809b190469b 100644
--- a/km3buu/output.py
+++ b/km3buu/output.py
@@ -33,8 +33,9 @@ try:
     libpath = environ.get("KM3NET_LIB")
     if libpath:
         libpath = Config().km3net_lib_path
-    ROOT.gSystem.Load(join(libpath, "libKM3NeTROOT.so"))
-except:
+    if ROOT.gSystem.Load(join(libpath, "libKM3NeTROOT.so")) != 0:
+        raise ModuleNotFoundError("KM3NeT dataformat library not found!")
+except ModuleNotFoundError:
     import warnings
     warnings.warn("KM3NeT dataformat library was not loaded.", ImportWarning)
 
diff --git a/km3buu/tests/test_output.py b/km3buu/tests/test_output.py
index 2932dc8742693ebdc87a326f0d8aec265dab37f4..0387b2482d61d5b486f053fdb7e35eb10fad4e61 100644
--- a/km3buu/tests/test_output.py
+++ b/km3buu/tests/test_output.py
@@ -32,7 +32,7 @@ try:
         libpath = Config().km3net_lib_path
     KM3NET_LIB_AVAILABLE = (ROOT.gSystem.Load(join(libpath,
                                                    "libKM3NeTROOT.so")) == 0)
-except ImportError:
+except ModuleNotFoundError:
     KM3NET_LIB_AVAILABLE = False