diff options
author | Eduardo Julian | 2022-08-11 16:50:42 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-08-11 16:50:42 -0400 |
commit | e5625dd840a8b8adc76987f649da254335d3d93a (patch) | |
tree | fb672669383525d90d462edf8c141f98bc953894 /lux-ruby/source | |
parent | 065e8a4d8122d4616b570496915d2c0e2c78cd6b (diff) |
Improved exception-definition macro.
Diffstat (limited to '')
-rw-r--r-- | lux-ruby/source/program.lux | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 534b78e34..b729daa3a 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -9,7 +9,7 @@ [control ["[0]" maybe] ["[0]" try (.only Try)] - ["[0]" exception (.only exception)] + ["[0]" exception (.only Exception)] ["[0]" io (.only IO io)] ["[0]" function] [concurrency @@ -251,7 +251,8 @@ failure)) {try.#Success output})))) -(exception (unknown_kind_of_object [object java/lang/Object]) +(exception.def (unknown_kind_of_object object) + (Exception java/lang/Object) (exception.report (list ["Class" (ffi.of_string (java/lang/Object::toString (java/lang/Object::getClass object)))] ["Object" (ffi.of_string (java/lang/Object::toString object))]))) @@ -280,7 +281,7 @@ _ (exception.except ..unknown_kind_of_object [(ffi.is java/lang/Object host_object)]))) -(exception .public nil_has_no_lux_representation) +(exception.def .public nil_has_no_lux_representation) (def (read host_object) Translator @@ -348,11 +349,13 @@ (useful_object_class again (as (Array java/lang/Object) value)) (ffi.is java/lang/Object value))))))) -(exception (invalid_variant_access [field Text]) +(exception.def (invalid_variant_access field) + (Exception Text) (exception.report (list ["Field" (%.text field)]))) -(exception (invalid_index [index java/lang/Object]) +(exception.def (invalid_index index) + (Exception java/lang/Object) (exception.report (list ["Class" (|> index java/lang/Object::getClass @@ -366,7 +369,8 @@ "[1]::[0]" ("static" [t] copyOfRange [[t] int int] [t])) -(exception (invalid_arity [arity Nat]) +(exception.def (invalid_arity arity) + (Exception Nat) (exception.report (list ["Arity" (%.nat arity)]))) @@ -602,7 +606,8 @@ (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime) (ffi.is org/jruby/runtime/builtin/IRubyObject)))))) -(exception (invalid_operation [method Text]) +(exception.def (invalid_operation method) + (Exception Text) (exception.report (list ["Method" (%.text method)]))) @@ -648,7 +653,8 @@ {.#None} (panic! (exception.error ..invalid_operation ["respond_to?"]))))))) -(exception (unknown_method [method Text]) +(exception.def (unknown_method method) + (Exception Text) (exception.report (list ["Method" (%.text method)]))) @@ -692,7 +698,8 @@ (useful_object_class lux_structure value) (as java/lang/Object value)))) -(exception (cannot_apply_a_non_function [object java/lang/Object]) +(exception.def (cannot_apply_a_non_function object) + (Exception java/lang/Object) (exception.report (list ["Non-function" (ffi.of_string (java/lang/Object::toString object))]))) @@ -772,8 +779,8 @@ [_ (run! content)] (run! (_.global (reference.artifact context)))))))))) -(for @.jvm (these (exception .public (invaid_phase_application [partial_application (List Any) - arity (List Any)]) +(for @.jvm (these (exception.def .public (invaid_phase_application [partial_application arity]) + (Exception [(List Any) (List Any)]) (exception.report (list ["Partial Application" (%.nat (list.size partial_application))] ["Arity" (%.nat (list.size arity))]))) |