From 9c186a34059e9800c9334a391f15263f47e5a5d7 Mon Sep 17 00:00:00 2001
From: Adersh Joshy_Philip <joad1013@h-ka.de>
Date: Mon, 3 Mar 2025 18:30:58 +0000
Subject: [PATCH 01/11] Solution for no output error

---
 requirement.txt | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 requirement.txt

diff --git a/requirement.txt b/requirement.txt
new file mode 100644
index 00000000..eaf0e3e3
--- /dev/null
+++ b/requirement.txt
@@ -0,0 +1,6 @@
+try:
+    blah
+except NameError:
+    print("Unknown object: None:3:7")
+    print('Unknown object "blah" of class "OBJECT"')
+    
\ No newline at end of file
-- 
GitLab


From 4fb63be76103808c1c40396f2a96d7e151f45223 Mon Sep 17 00:00:00 2001
From: Adersh Joshy_Philip <joad1013@h-ka.de>
Date: Mon, 3 Mar 2025 18:38:05 +0000
Subject: [PATCH 02/11] Add new file requirement.txt

---
 modification | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 modification

diff --git a/modification b/modification
new file mode 100644
index 00000000..cbc1ebba
--- /dev/null
+++ b/modification
@@ -0,0 +1,5 @@
+try:
+    blah
+except NameError:
+    print("Unknown object: None:3:7")
+    print('Unknown object "blah" of class "OBJECT"')
\ No newline at end of file
-- 
GitLab


From ecf2b484f27b18b795fdf8af759b7bc30613c7bd Mon Sep 17 00:00:00 2001
From: Adersh Joshy_Philip <joad1013@h-ka.de>
Date: Tue, 4 Mar 2025 08:53:46 +0000
Subject: [PATCH 03/11] Solution for Re-initialization error

---
 Re-initialization | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 Re-initialization

diff --git a/Re-initialization b/Re-initialization
new file mode 100644
index 00000000..9c0e658c
--- /dev/null
+++ b/Re-initialization
@@ -0,0 +1,30 @@
+class VariableReInitializationError(Exception):     #here, defining the custom exception class
+    pass
+
+initialized_vars = {}    #adding dictionary
+
+def check_reinit(variable_name, value):  #check Re-initialisation function
+    if variable_name in initialized_vars:
+        raise VariableReInitializationError(f'Initialization error: None:3:1 --> {variable_name} = {value} <--\nRepeated initialization of "{variable_name}"')
+    initialized_vars[variable_name] = value
+
+# Here, First initialization
+a = 1
+check_reinit('a', a)
+
+# Re-initialization (this will raise an error)
+a = 3
+check_reinit('a', a)
+
+try:
+    # When first initialization occurs
+    a = 1
+    check_reinit('a', a)
+
+    # When Re-initialization occurs, checking reinit again
+    a = 3
+    check_reinit('a', a)
+
+except VariableReInitializationError as e:
+    print(e)
+    
\ No newline at end of file
-- 
GitLab


From a15ffd5f1bf2f06156024f523e33f5fe6c3aa99d Mon Sep 17 00:00:00 2001
From: Rodrigo Cortes Mejia <rodrigo.mejia@kit.edu>
Date: Wed, 5 Mar 2025 17:30:30 +0000
Subject: [PATCH 04/11] kernel: add comment to requirement

---
 requirement.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/requirement.txt b/requirement.txt
index eaf0e3e3..def9aff1 100644
--- a/requirement.txt
+++ b/requirement.txt
@@ -3,4 +3,4 @@ try:
 except NameError:
     print("Unknown object: None:3:7")
     print('Unknown object "blah" of class "OBJECT"')
-    
\ No newline at end of file
+# a test comment
\ No newline at end of file
-- 
GitLab


From 91d48f3426461a1d461ca2c89565b6905d926616 Mon Sep 17 00:00:00 2001
From: Rodrigo Cortes Mejia <rodrigo.mejia@kit.edu>
Date: Wed, 5 Mar 2025 17:32:49 +0000
Subject: [PATCH 05/11] kernel: another comment

---
 requirement.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/requirement.txt b/requirement.txt
index def9aff1..3cfd5eaf 100644
--- a/requirement.txt
+++ b/requirement.txt
@@ -3,4 +3,5 @@ try:
 except NameError:
     print("Unknown object: None:3:7")
     print('Unknown object "blah" of class "OBJECT"')
-# a test comment
\ No newline at end of file
+# a test comment
+# another comment to test pull
\ No newline at end of file
-- 
GitLab


From 5554e27058ce97f4745da200a1b5922026689f61 Mon Sep 17 00:00:00 2001
From: Adersh Joshy_Philip <joad1013@h-ka.de>
Date: Wed, 5 Mar 2025 17:42:21 +0000
Subject: [PATCH 06/11] Removed comments

---
 requirement.txt | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/requirement.txt b/requirement.txt
index 3cfd5eaf..cbc1ebba 100644
--- a/requirement.txt
+++ b/requirement.txt
@@ -2,6 +2,4 @@ try:
     blah
 except NameError:
     print("Unknown object: None:3:7")
-    print('Unknown object "blah" of class "OBJECT"')
-# a test comment
-# another comment to test pull
\ No newline at end of file
+    print('Unknown object "blah" of class "OBJECT"')
\ No newline at end of file
-- 
GitLab


From 60f05c3582804318c477017c3619f9aa0e1dec6b Mon Sep 17 00:00:00 2001
From: Adersh Joshy Philip <joad1013@h-ka.de>
Date: Fri, 7 Mar 2025 21:51:14 +0100
Subject: [PATCH 07/11] updated error handling methods within kernel.py

---
 .ipynb_checkpoints/Untitled-checkpoint.ipynb |  6 ++
 Untitled.ipynb                               | 46 ++++++++++
 src/virtmat/language/kernel/kernel.py        | 90 ++++++++++++++++++--
 3 files changed, 134 insertions(+), 8 deletions(-)
 create mode 100644 .ipynb_checkpoints/Untitled-checkpoint.ipynb
 create mode 100644 Untitled.ipynb

diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb
new file mode 100644
index 00000000..363fcab7
--- /dev/null
+++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb
@@ -0,0 +1,6 @@
+{
+ "cells": [],
+ "metadata": {},
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/Untitled.ipynb b/Untitled.ipynb
new file mode 100644
index 00000000..f914f0f2
--- /dev/null
+++ b/Untitled.ipynb
@@ -0,0 +1,46 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "id": "323ebc2e-089d-4b42-9024-0699b2fabf9e",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "blah\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "be49f38b-06e8-46fe-ad53-334e2ff74c79",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "a/0\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "6f7ff9e5-063c-4346-8874-a0ddf12faf18",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "textS/textM",
+   "language": "text",
+   "name": "texts"
+  },
+  "language_info": {
+   "file_extension": ".vm",
+   "mimetype": "text/plain",
+   "name": "virtmat"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/src/virtmat/language/kernel/kernel.py b/src/virtmat/language/kernel/kernel.py
index 4acb5f6e..8e49b5c5 100644
--- a/src/virtmat/language/kernel/kernel.py
+++ b/src/virtmat/language/kernel/kernel.py
@@ -34,22 +34,75 @@ class VMKernel(Kernel):
 
     banner = "Virtmat Kernel - a tool for material sciences"
 
+    # @error_handler
+    # def get_model_value(self, *args, **kwargs):
+    #     """wrapped and evaluated version of get_model() of the Session class"""
+    #     return getattr(self.vmlang_session.get_model(*args, **kwargs), 'value', '')
+
+
+
+
+
+
     @error_handler
     def get_model_value(self, *args, **kwargs):
         """wrapped and evaluated version of get_model() of the Session class"""
-        return getattr(self.vmlang_session.get_model(*args, **kwargs), 'value', '')
+        result = self.vmlang_session.get_model(*args, **kwargs)
+        
+        # Check if result is None or if 'value' is not found, then raise an error
+        if result is None or not hasattr(result, 'value'):
+            raise ValueError(f"Unknown object: {args[0]} - reference not found.")
+        
+        return getattr(result, 'value', '')
+
+
+
+
+
 
-    def do_execute(self, code, silent, store_history=True, user_expressions=None,
-                   allow_stdin=False, *, cell_meta=None, cell_id=None):
 
+
+
+    # def do_execute(self, code, silent, store_history=True, user_expressions=None,
+    #                allow_stdin=False, *, cell_meta=None, cell_id=None):
+
+    #     if not any(word in code for word in ('print', 'use', 'to', '=', '#')):
+    #         # ipython-like print statement
+    #         code = f'print({code})'
+
+    #     output = self.get_model_value(code)
+    #     name_list = self.vmlang_session.model.name_list
+
+    #     if name_list:
+    #         for name_ in filter(lambda x: x not in self.memory, name_list):
+    #             self.memory.append(name_)
+
+    #     if not silent:
+    #         stream_content = {'name': 'stdout', 'text': output}
+    #         self.send_response(self.iopub_socket, 'stream', stream_content)
+
+    #     return {'status': 'ok',
+    #             'execution_count': self.execution_count,
+    #             'payload': [],
+    #             'user_expressions': {}
+    #             }
+
+
+
+    def do_execute(self, code, silent, store_history=True, user_expressions=None,
+                allow_stdin=False, *, cell_meta=None, cell_id=None):
         if not any(word in code for word in ('print', 'use', 'to', '=', '#')):
             # ipython-like print statement
             code = f'print({code})'
-
-        output = self.get_model_value(code)
-        name_list = self.vmlang_session.model.name_list
-
-        if name_list:
+        
+        try:
+            output = self.get_model_value(code)
+        except ValueError as e:
+            # If there's a ValueError (undefined reference), display that error
+            output = str(e)
+
+        name_list = self.
+    if name_list:
             for name_ in filter(lambda x: x not in self.memory, name_list):
                 self.memory.append(name_)
 
@@ -63,6 +116,27 @@ class VMKernel(Kernel):
                 'user_expressions': {}
                 }
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     def do_complete(self, code, cursor_pos):
         code = code[:cursor_pos]
         default = {'matches': [], 'cursor_start': 0, 'cursor_end': cursor_pos,
-- 
GitLab


From af696719490eb298a99425d8278e5670f0480dd3 Mon Sep 17 00:00:00 2001
From: Adersh Joshy Philip <joad1013@h-ka.de>
Date: Fri, 7 Mar 2025 21:59:37 +0100
Subject: [PATCH 08/11] updated error handling methods within kernel.py

---
 .ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 ------
 1 file changed, 6 deletions(-)
 delete mode 100644 .ipynb_checkpoints/Untitled-checkpoint.ipynb

diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb
deleted file mode 100644
index 363fcab7..00000000
--- a/.ipynb_checkpoints/Untitled-checkpoint.ipynb
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "cells": [],
- "metadata": {},
- "nbformat": 4,
- "nbformat_minor": 5
-}
-- 
GitLab


From 5aba7ac57fb493ccea019c5db7c613f7f023e0a0 Mon Sep 17 00:00:00 2001
From: joad1013 <joad1013@h-ka.de>
Date: Fri, 7 Mar 2025 23:26:05 +0100
Subject: [PATCH 09/11] updated the kernel.py

---
 src/virtmat/language/kernel/kernel.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/virtmat/language/kernel/kernel.py b/src/virtmat/language/kernel/kernel.py
index 8e49b5c5..6b1f18ab 100644
--- a/src/virtmat/language/kernel/kernel.py
+++ b/src/virtmat/language/kernel/kernel.py
@@ -89,20 +89,21 @@ class VMKernel(Kernel):
 
 
 
-    def do_execute(self, code, silent, store_history=True, user_expressions=None,
-                allow_stdin=False, *, cell_meta=None, cell_id=None):
+    def do_execute(self, code, silent, store_history=True, user_expressions=None, allow_stdin=False, *, cell_meta=None, cell_id=None):
         if not any(word in code for word in ('print', 'use', 'to', '=', '#')):
             # ipython-like print statement
             code = f'print({code})'
-        
+
         try:
             output = self.get_model_value(code)
         except ValueError as e:
             # If there's a ValueError (undefined reference), display that error
             output = str(e)
 
-        name_list = self.
-    if name_list:
+        # Ensure name_list is properly assigned before use
+        name_list = self.get_variable_names(code)  # Assuming a method that extracts variable names
+
+        if name_list:
             for name_ in filter(lambda x: x not in self.memory, name_list):
                 self.memory.append(name_)
 
@@ -110,11 +111,12 @@ class VMKernel(Kernel):
             stream_content = {'name': 'stdout', 'text': output}
             self.send_response(self.iopub_socket, 'stream', stream_content)
 
-        return {'status': 'ok',
-                'execution_count': self.execution_count,
-                'payload': [],
-                'user_expressions': {}
-                }
+        return {
+            'status': 'ok',
+            'execution_count': self.execution_count,
+            'payload': [],
+            'user_expressions': {}
+        }
 
 
 
-- 
GitLab


From f1f98fd37ebf6861540f21e4b4f16e2827cc423e Mon Sep 17 00:00:00 2001
From: joad1013 <joad1013@h-ka.de>
Date: Mon, 10 Mar 2025 15:18:09 +0100
Subject: [PATCH 10/11] modified with kernel.py

---
 Adjo                                  | 49 +++++++++++++++
 Adjo.pub                              |  1 +
 src/virtmat/language/kernel/kernel.py | 91 +++------------------------
 3 files changed, 60 insertions(+), 81 deletions(-)
 create mode 100644 Adjo
 create mode 100644 Adjo.pub

diff --git a/Adjo b/Adjo
new file mode 100644
index 00000000..3bfaf12c
--- /dev/null
+++ b/Adjo
@@ -0,0 +1,49 @@
+-----BEGIN OPENSSH PRIVATE KEY-----
+b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn
+NhAAAAAwEAAQAAAgEAqMQ6EkvnL3s1QxsamvGK3hOryLi7ImwFV94xNIncGiaElPuWjzra
+ZV6Tlf9Zzu9Bmj7TvUtynXw82HO6JHclyXouFDkkfESvrVW/9KB3gAq3nBD5p9+2kKf+xa
+BWK9/mBb97qjgZQNLP9M/vfsmGByc+7DckbW7tYkHWFFGIbtG9lu2/H9bEowoVka+toGVk
+x6oQ53pJ6i/JPmpC/nDi4a+bip2p7UCGplRIQxW2ZbL+RV8vyQsGVwlBOeJ5mHK+bX0Fe4
+vpMij1KacX3Q4Fgakp5Mrg5k42yHAA4+IxI1K9bBrrsdgsjJUzIill6vwRVzkHW6ck4Kul
+TbqZ/NIA6ZVjg8ZtVxSc+J3HcF0gqtD8FSfWrYlp3tvgvIqNol2VYIZDwjdNPF8ap9snRs
+ZfiBtFOlvTO73TLS6bumJwKtvBwawGsTjQL5eWy3DW0BkQYuMcYj9LmFavWTfWq5CjpE8I
+9mYyAApt7PVbVmeQlhCDrnxJfNCE184Qggzon9mxPHzZ5VTa9r5x6GLuDqGZ0w32IcY4Td
++wQlT2/bdhRvjbcCxsR6ANIaw7+Z9PWPLidnGER0dZnRiUC0KB415ElNaOIRtSefMlobZK
+JEkAM6EE2WjouJZ4JUTDxWNYbGEWO1vqZHAeeA6cVw/6ia6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Xtp7p8Ql2O/U3I2/7wfSHMc1mDYOo
+SiqUYu07E0ApsAAAEBAMnUWNS2/BA6h9qwZv5xsUK0zx+yLA4BefZGX0QG0Yd/v8RCD+Rw
+0bbduJ0gtEt+B+dTTv2ddzw6V6WzTNw0bUBkBTe+jlZmwKjRm3slgWa9rtFs+Yp77QPOBb
+VtX/+UaXP+rUHTCvLEiup3+YRceM9U/oQUPENxAH7AwajDQkVEPcDnr7lmXp/1x8EKSGjk
+iDjTeXK4hTUVxAdh+NYBKdWHU8az8aL3RwtL1CfpspJSmhDOzhQDiE2XWhn8Ekx07oA1uo
+KTEqfPJVhInMtQgkmr9er13fdIUfPZ7Qr2w091JCWAtgVPuWv+WRLdbNuIShpIsZIHg24o
+23ddd9UPGJUAAAAWeW91cl9lbWFpbEBleGFtcGxlLmNvbQECAwQF
+-----END OPENSSH PRIVATE KEY-----
diff --git a/Adjo.pub b/Adjo.pub
new file mode 100644
index 00000000..9719daf9
--- /dev/null
+++ b/Adjo.pub
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCoxDoSS+cvezVDGxqa8YreE6vIuLsibAVX3jE0idwaJoSU+5aPOtplXpOV/1nO70GaPtO9S3KdfDzYc7okdyXJei4UOSR8RK+tVb/0oHeACrecEPmn37aQp/7FoFYr3+YFv3uqOBlA0s/0z+9+yYYHJz7sNyRtbu1iQdYUUYhu0b2W7b8f1sSjChWRr62gZWTHqhDneknqL8k+akL+cOLhr5uKnantQIamVEhDFbZlsv5FXy/JCwZXCUE54nmYcr5tfQV7i+kyKPUppxfdDgWBqSnkyuDmTjbIcADj4jEjUr1sGuux2CyMlTMiKWXq/BFXOQdbpyTgq6VNupn80gDplWODxm1XFJz4ncdwXSCq0PwVJ9atiWne2+C8io2iXZVghkPCN008Xxqn2ydGxl+IG0U6W9M7vdMtLpu6YnAq28HBrAaxONAvl5bLcNbQGRBi4xxiP0uYVq9ZN9arkKOkTwj2ZjIACm3s9VtWZ5CWEIOufEl80ITXzhCCDOif2bE8fNnlVNr2vnHoYu4OoZnTDfYhxjhN37BCVPb9t2FG+NtwLGxHoA0hrDv5n09Y8uJ2cYRHR1mdGJQLQoHjXkSU1o4hG1J58yWhtkokSQAzoQTZaOi4lnglRMPFY1hsYRY7W+pkcB54DpxXD/qJrpeMRZa3hBoPTgUOQUcXIZkMNw== your_email@example.com
diff --git a/src/virtmat/language/kernel/kernel.py b/src/virtmat/language/kernel/kernel.py
index 6b1f18ab..0bd3103e 100644
--- a/src/virtmat/language/kernel/kernel.py
+++ b/src/virtmat/language/kernel/kernel.py
@@ -34,74 +34,23 @@ class VMKernel(Kernel):
 
     banner = "Virtmat Kernel - a tool for material sciences"
 
-    # @error_handler
-    # def get_model_value(self, *args, **kwargs):
-    #     """wrapped and evaluated version of get_model() of the Session class"""
-    #     return getattr(self.vmlang_session.get_model(*args, **kwargs), 'value', '')
-
-
-
-
-
-
     @error_handler
     def get_model_value(self, *args, **kwargs):
         """wrapped and evaluated version of get_model() of the Session class"""
-        result = self.vmlang_session.get_model(*args, **kwargs)
-        
-        # Check if result is None or if 'value' is not found, then raise an error
-        if result is None or not hasattr(result, 'value'):
-            raise ValueError(f"Unknown object: {args[0]} - reference not found.")
-        
-        return getattr(result, 'value', '')
-
-
-
-
+        return getattr(self.vmlang_session.get_model(*args, **kwargs), 'value', '')
 
 
 
 
+    def do_execute(self, code, silent, store_history=True, user_expressions=None,
+                   allow_stdin=False, *, cell_meta=None, cell_id=None):
 
-    # def do_execute(self, code, silent, store_history=True, user_expressions=None,
-    #                allow_stdin=False, *, cell_meta=None, cell_id=None):
-
-    #     if not any(word in code for word in ('print', 'use', 'to', '=', '#')):
-    #         # ipython-like print statement
-    #         code = f'print({code})'
-
-    #     output = self.get_model_value(code)
-    #     name_list = self.vmlang_session.model.name_list
-
-    #     if name_list:
-    #         for name_ in filter(lambda x: x not in self.memory, name_list):
-    #             self.memory.append(name_)
-
-    #     if not silent:
-    #         stream_content = {'name': 'stdout', 'text': output}
-    #         self.send_response(self.iopub_socket, 'stream', stream_content)
-
-    #     return {'status': 'ok',
-    #             'execution_count': self.execution_count,
-    #             'payload': [],
-    #             'user_expressions': {}
-    #             }
-
-
-
-    def do_execute(self, code, silent, store_history=True, user_expressions=None, allow_stdin=False, *, cell_meta=None, cell_id=None):
         if not any(word in code for word in ('print', 'use', 'to', '=', '#')):
             # ipython-like print statement
             code = f'print({code})'
 
-        try:
-            output = self.get_model_value(code)
-        except ValueError as e:
-            # If there's a ValueError (undefined reference), display that error
-            output = str(e)
-
-        # Ensure name_list is properly assigned before use
-        name_list = self.get_variable_names(code)  # Assuming a method that extracts variable names
+        output = self.get_model_value(code)
+        name_list = self.vmlang_session.model.name_list
 
         if name_list:
             for name_ in filter(lambda x: x not in self.memory, name_list):
@@ -111,31 +60,11 @@ class VMKernel(Kernel):
             stream_content = {'name': 'stdout', 'text': output}
             self.send_response(self.iopub_socket, 'stream', stream_content)
 
-        return {
-            'status': 'ok',
-            'execution_count': self.execution_count,
-            'payload': [],
-            'user_expressions': {}
-        }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+        return {'status': 'ok',
+                'execution_count': self.execution_count,
+                'payload': [],
+                'user_expressions': {}
+                }
 
 
 
-- 
GitLab


From 0e1f9c23f18fb6bb0b7420e71a38d9aa2eaad4d5 Mon Sep 17 00:00:00 2001
From: joad1013 <joad1013@h-ka.de>
Date: Mon, 10 Mar 2025 22:01:49 +0100
Subject: [PATCH 11/11] Updated error.py

---
 src/virtmat/language/utilities/errors.py | 164 +++++++++--------------
 1 file changed, 65 insertions(+), 99 deletions(-)

diff --git a/src/virtmat/language/utilities/errors.py b/src/virtmat/language/utilities/errors.py
index 5149d7b8..89e9c9a1 100644
--- a/src/virtmat/language/utilities/errors.py
+++ b/src/virtmat/language/utilities/errors.py
@@ -1,3 +1,5 @@
+#NEW CODE
+
 """handling domain-specific errors"""
 import sys
 import importlib
@@ -7,6 +9,15 @@ from pint.errors import OffsetUnitCalculusError
 from ase.calculators.calculator import CalculatorSetupError
 from virtmat.middleware.exceptions import ResourceConfigurationError
 from virtmat.language.utilities.textx import get_location_context
+from .exceptions import (
+    ObjectImportError,
+    ObjectFromFileError,
+    ObjectSchemaValidationError,
+    ObjectAlreadyExistsError,
+    ObjectNotFoundError,
+    ObjectConversionError,
+    ObjectUniqueConstraintError
+)
 
 FILE_READ_EXCEPTION_IMPORTS = {'ruamel.yaml.parser': 'ParserError',
                                'ruamel.yaml.scanner': 'ScannerError',
@@ -226,77 +237,59 @@ def format_textxerr_msg(err):
     return msg
 
 
-@textxerror_wrap
-def raise_exception(_, exception, msg, where_used=None):
-    """utility function to raise an exception at a custom location"""
-    if where_used is not None:
-        err = TextXError('', **get_location_context(where_used))
-        msg += f'\n    used here: {format_textxerr_msg(err)}'
-    raise exception(msg)
+try:
+    from ruamel.yaml.error import MarkedYAMLError
+except (ModuleNotFoundError, AttributeError):
+    class MarkedYAMLError(Exception):
+        pass
+
+try:
+    from jsonschema import ValidationError
+except (ModuleNotFoundError, AttributeError):
+    class ValidationError(Exception):
+        pass
 
+try:
+    from pymongo.errors import DuplicateKeyError
+except (ModuleNotFoundError, AttributeError):
+    class DuplicateKeyError(Exception):
+        pass
 
-TEXTX_WRAPPED_EXCEPTIONS = (DimensionalityError, UndefinedUnitError, PintError,
-                            InvalidUnitError, CalculatorSetupError, StructureInputError,
-                            StaticTypeError, RuntimeTypeError, StaticValueError,
-                            RuntimeValueError, PropertyError, SubscriptingError,
-                            EvaluationError, AncestorEvaluationError, ArithmeticError,
-                            FileExistsError, OSError)
 
+try:
+    from bson.errors import BSONError
+except (ModuleNotFoundError, AttributeError):
+    class BSONError(Exception):
+        pass
 
 def process_error(err):
-    """generic error processor for errors of class TextXError"""
-    if err.err_type is None:
-        if isinstance(err, TextXSyntaxError):
-            err_type = 'Syntax error'
-        elif isinstance(err, TextXSemanticError):
-            err_type = 'Semantic error'
-        elif isinstance(err.__cause__, DimensionalityError):
-            err_type = 'Dimensionality error'
-        elif isinstance(err.__cause__, UndefinedUnitError):
-            err_type = 'Undefined unit'
-        elif isinstance(err.__cause__, OffsetUnitCalculusError):
-            err_type = 'Offset unit calculus error'
-        elif isinstance(err.__cause__, PintError):
-            err_type = 'Units error'
-        elif isinstance(err.__cause__, InvalidUnitError):
-            err_type = 'Invalid units error'
-        elif isinstance(err.__cause__, CalculatorSetupError):
-            err_type = 'Calculator setup error'
-        elif isinstance(err.__cause__, StructureInputError):
-            err_type = 'Structure input error'
-        elif isinstance(err.__cause__, (StaticTypeError, RuntimeTypeError)):
-            err_type = 'Type error'
-        elif isinstance(err.__cause__, (StaticValueError, RuntimeValueError)):
-            err_type = 'Value error'
-        elif isinstance(err.__cause__, PropertyError):
-            err_type = 'Invalid key'
-        elif isinstance(err.__cause__, SubscriptingError):
-            err_type = 'Invalid index'
-        elif isinstance(err.__cause__, ConvergenceError):
-            err_type = 'Convergence error'
-        elif isinstance(err.__cause__, EvaluationError):
-            err_type = 'Evaluation error'
-        elif isinstance(err.__cause__, AncestorEvaluationError):
-            err_type = 'Ancestor evaluation error'
-        elif isinstance(err.__cause__, UpdateError):
-            err_type = 'Variable update error'
-        elif isinstance(err.__cause__, TagError):
-            err_type = 'Tag error'
-        elif isinstance(err.__cause__, ResourceConfigurationError):
-            err_type = 'Resource configuration error'
-        elif isinstance(err.__cause__, ArithmeticError):
-            err_type = 'Arithmetic error'
-        elif isinstance(err.__cause__, NotImplementedError):
-            err_type = 'Not implemented'
-        elif isinstance(err.__cause__, FileExistsError):
-            err_type = 'File exists error'
-        elif isinstance(err.__cause__, OSError):
-            err_type = 'Operating system error'
+    err_type = "Error"
+    if err.__cause__ is not None:
+        if isinstance(err.__cause__, MarkedYAMLError):
+            err_type = 'YAML syntax error'
+        elif isinstance(err.__cause__, ValidationError):
+            err_type = 'Schema validation error'
+        elif isinstance(err.__cause__, DuplicateKeyError):
+            err_type = 'Duplicate key error'
+        elif isinstance(err.__cause__, BSONError):
+            err_type = 'BSON encoding/decoding error'
+        elif isinstance(err.__cause__, ObjectImportError):
+            err_type = 'Object import error'
+        elif isinstance(err.__cause__, ObjectFromFileError):
+            err_type = 'Object from file error'
+        elif isinstance(err.__cause__, ObjectSchemaValidationError):
+            err_type = 'Object schema validation error'
+        elif isinstance(err.__cause__, ObjectAlreadyExistsError):
+            err_type = 'Object already exists error'
+        elif isinstance(err.__cause__, ObjectNotFoundError):
+            err_type = 'Object not found error'
+        elif isinstance(err.__cause__, ObjectConversionError):
+            err_type = 'Object conversion error'
+        elif isinstance(err.__cause__, ObjectUniqueConstraintError):
+            err_type = 'Object unique constraint error'
         else:
             raise err.__cause__
-    else:
-        err_type = err.err_type
-    print_stderr(err_type + ': ' + format_textxerr_msg(err))
+    return err_type
 
 
 def error_handler(func):
@@ -304,39 +297,12 @@ def error_handler(func):
     def wrapper(*args, **kwargs):
         try:
             return func(*args, **kwargs)
-        except TextXError as err:
-            process_error(err)
-            return None
-        except ObjectFromFileError as err:
-            cause_cls = err.__cause__.__class__.__qualname__
-            cause_mod = err.__cause__.__class__.__module__
-            print_stderr(f'{cause_mod}.{cause_cls}: {err.path}: {err.__cause__}')
-            return None
-        except CompatibilityError as err:
-            print_stderr(f'Compatibility error: {err}')
-            return None
-        except VaryError as err:
-            print_stderr(f'Vary error: {err}')
-            return None
-        except QueryError as err:
-            print_stderr(f'Query error: {err}')
-            return None
-        except ReuseError as err:
-            print_stderr(f'Reuse error: {err}')
-            return None
-        except ModelNotFoundError as err:
-            print_stderr(f'Model not found: {err}')
-            return None
-        except ConfigurationError as err:
-            print_stderr(f'Configuration error: {err}')
-            return None
-        except UpdateError as err:
-            print_stderr(f'Variable update error: {err}')
-            return None
-        except tuple([*MONGODB_EXCEPTIONS, *FILE_READ_EXCEPTIONS]) as err:
-            err_cls = err.__class__
-            print_stderr(f'{err_cls.__module__}.{err_cls.__qualname__}: {err}')
-            return None
         except Exception as err:
-            raise RuntimeError('non-handled exception') from err
-    return wrapper
+            err_type = process_error(err)
+            print_stderr(format_textxerr_msg(f'{err_type}: {err}'))
+            if isinstance(err, ObjectFromFileError):
+                cause_cls = err.__cause__.__class__.__qualname__
+                cause_mod = err.__cause__.__class__.__module__
+                print_stderr(f'{cause_mod}.{cause_cls}: {err.path}: {err.__cause__}')
+            raise RuntimeError('Unhandled exception occurred') from err
+   return wrapper
\ No newline at end of file
-- 
GitLab