From: Iqbal Ansari Date: Mon, 22 Aug 2016 17:19:11 +0000 (+0530) Subject: Introduce types mal-runtime-exception and mal-user-exception types X-Git-Url: https://git.hcoop.net/jackhill/mal.git/commitdiff_plain/e844f5c872a4ed1e455920700b01bf5be7a895b4 Introduce types mal-runtime-exception and mal-user-exception types All the exceptions generated by runtime inherit from mal-user-exception while user exceptions inherit from mal-user-exception --- diff --git a/common_lisp/core.lisp b/common_lisp/core.lisp index 8659aeda..f86c1af3 100644 --- a/common_lisp/core.lisp +++ b/common_lisp/core.lisp @@ -8,7 +8,7 @@ (in-package :core) -(define-condition index-error (types:mal-error) +(define-condition index-error (types:mal-runtime-exception) ((size :initarg :size :reader size) (index :initarg :index :reader index) (sequence :initarg :sequence :reader sequence)) diff --git a/common_lisp/env.lisp b/common_lisp/env.lisp index 59aa3f2e..bf59ba44 100644 --- a/common_lisp/env.lisp +++ b/common_lisp/env.lisp @@ -9,14 +9,14 @@ (in-package :env) -(define-condition undefined-symbol (types:mal-error) +(define-condition undefined-symbol (types:mal-runtime-exception) ((symbol :initarg :symbol :reader symbol)) (:report (lambda (condition stream) (format stream - "Symbol ~a is undefined" + "'~a' not found" (symbol condition))))) -(define-condition arity-mismatch (types:mal-error) +(define-condition arity-mismatch (types:mal-runtime-exception) ((required :initarg :required :reader required) (provided :initarg :provided :reader provided)) (:report (lambda (condition stream) diff --git a/common_lisp/types.lisp b/common_lisp/types.lisp index 9a4a83ba..d8a39889 100644 --- a/common_lisp/types.lisp +++ b/common_lisp/types.lisp @@ -20,6 +20,11 @@ :fn :builtin-fn :any + :mal-exception + ;; User exceptions + :mal-user-exception + ;; Exceptions raised by the runtime itself + :mal-runtime-exception ;; Error :mal-error ;; Helpers @@ -33,6 +38,15 @@ (define-condition mal-error (error) nil) +(define-condition mal-exception (error) + nil) + +(define-condition mal-runtime-exception (mal-exception) + nil) + +(define-condition mal-user-exception (mal-exception) + ((data :accessor mal-exception-data :initarg :data))) + (defclass mal-type () ((value :accessor mal-value :initarg :value) (meta :accessor mal-meta :initarg :meta :initform nil)