diff options
Diffstat (limited to 'stdlib/source/library/lux/control/exception.lux')
-rw-r--r-- | stdlib/source/library/lux/control/exception.lux | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 6d8b4e5e7..22b882f85 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -1,4 +1,5 @@ -(.module: {#.doc "Exception-handling functionality."} +(.module: + {#.doc "Pure-Lux exception-handling functionality."} [library [lux #* ["." macro] @@ -76,7 +77,7 @@ (All [e] (-> (Exception e) e Text)) ((get@ #..constructor exception) message)) -(def: #export (throw exception message) +(def: #export (except exception message) {#.doc "Decorate an error message with an Exception and lift it into the error-handling context."} (All [e a] (-> (Exception e) e (Try a))) (#//.Failure (..construct exception message))) @@ -85,11 +86,11 @@ (All [e] (-> (Exception e) e Bit (Try Any))) (if test (#//.Success []) - (..throw exception message))) + (..except exception message))) (syntax: #export (exception: {export |export|.parser} {t_vars (p.default (list) (s.tuple (p.some |type_variable|.parser)))} - {[name inputs] (p.either (p.and s.local_identifier (wrap (list))) + {[name inputs] (p.either (p.and s.local_identifier (in (list))) (s.form (p.and s.local_identifier (p.some |input|.parser))))} {body (p.maybe s.any)}) {#.doc (doc "Define a new exception type." @@ -106,15 +107,15 @@ [current_module meta.current_module_name #let [descriptor ($_ text\compose "{" current_module "." name "}" text.new_line) g!self (code.local_identifier name)]] - (wrap (list (` (def: (~+ (|export|.format export)) - (~ g!self) - (All [(~+ (list\map |type_variable|.format t_vars))] - (..Exception [(~+ (list\map (get@ #|input|.type) inputs))])) - (let [(~ g!descriptor) (~ (code.text descriptor))] - {#..label (~ g!descriptor) - #..constructor (function ((~ g!self) [(~+ (list\map (get@ #|input|.binding) inputs))]) - ((~! text\compose) (~ g!descriptor) - (~ (maybe.default (' "") body))))}))))) + (in (list (` (def: (~+ (|export|.format export)) + (~ g!self) + (All [(~+ (list\map |type_variable|.format t_vars))] + (..Exception [(~+ (list\map (get@ #|input|.type) inputs))])) + (let [(~ g!descriptor) (~ (code.text descriptor))] + {#..label (~ g!descriptor) + #..constructor (function ((~ g!self) [(~+ (list\map (get@ #|input|.binding) inputs))]) + ((~! text\compose) (~ g!descriptor) + (~ (maybe.default (' "") body))))}))))) ))) (def: (report' entries) @@ -149,9 +150,9 @@ tail)))) (syntax: #export (report {entries (p.many (s.tuple (p.and s.any s.any)))}) - (wrap (list (` ((~! report') (list (~+ (|> entries - (list\map (function (_ [header message]) - (` [(~ header) (~ message)]))))))))))) + (in (list (` ((~! report') (list (~+ (|> entries + (list\map (function (_ [header message]) + (` [(~ header) (~ message)]))))))))))) (def: #export (enumerate format entries) (All [a] |