aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/control/exception.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/control/exception.lux')
-rw-r--r--stdlib/source/lux/control/exception.lux18
1 files changed, 12 insertions, 6 deletions
diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux
index 6bccbeec8..ef0419b98 100644
--- a/stdlib/source/lux/control/exception.lux
+++ b/stdlib/source/lux/control/exception.lux
@@ -6,7 +6,9 @@
[macro]
(macro [code]
["s" syntax #+ syntax: Syntax]
- (syntax [common]))))
+ (syntax ["cs" common]
+ (common ["csr" reader]
+ ["csw" writer])))))
## [Types]
(type: #export Exception
@@ -30,9 +32,13 @@
(#R;Success output)
(#R;Error error)
- (if (text;starts-with? (exception "") error)
- (#R;Success (then error))
- (#R;Error error))))
+ (let [reference (exception "")]
+ (if (text;starts-with? reference error)
+ (#R;Success (|> error
+ (text;clip (text;size reference) (text;size error))
+ assume
+ then))
+ (#R;Error error)))))
(def: #export (otherwise to-do try)
{#;doc "If no handler could be found to catch the exception, then run a function as a last-resort measure."}
@@ -55,13 +61,13 @@
(All [a] (-> Exception Text (Result a)))
(#R;Error (exception message)))
-(syntax: #export (exception: [_ex-lev common;export] [name s;local-symbol])
+(syntax: #export (exception: [_ex-lev csr;export] [name s;local-symbol])
{#;doc (doc "Define a new exception type."
"It moslty just serves as a way to tag error messages for later catching."
(exception: #export Some-Exception))}
(do @
[current-module macro;current-module-name
#let [g!message (code;symbol ["" "message"])]]
- (wrap (list (` (def: (~@ (common;gen-export _ex-lev)) ((~ (code;symbol ["" name])) (~ g!message))
+ (wrap (list (` (def: (~@ (csw;export _ex-lev)) ((~ (code;symbol ["" name])) (~ g!message))
Exception
($_ _Text/append_ "[" (~ (code;text current-module)) ";" (~ (code;text name)) "]\t" (~ g!message))))))))