|
1 | 1 | //! Testing error reporting and handling. |
2 | 2 |
|
3 | | -use emacs::{defun, CallEnv, Env, Result, Value, OnceGlobalRef}; |
| 3 | +use emacs::{defun, CallEnv, Env, Result, Value}; |
4 | 4 | use emacs::ErrorKind::{self, Signal, Throw}; |
5 | 5 | use emacs::ResultExt; |
6 | 6 |
|
@@ -87,29 +87,22 @@ fn parse_arg(env: &CallEnv) -> Result<String> { |
87 | 87 | Ok(s) |
88 | 88 | } |
89 | 89 |
|
| 90 | +emacs::define_errors! { |
| 91 | + emacs_module_rs_test_error "Hello" (rust_error) |
| 92 | + error_defined_without_parent "No error message" |
| 93 | +} |
| 94 | + |
90 | 95 | pub fn init(env: &Env) -> Result<()> { |
91 | 96 | emacs::__export_functions! { |
92 | 97 | env, format!("{}error:", *MODULE_PREFIX), { |
93 | 98 | "parse-arg" => (parse_arg , 2..5), |
94 | 99 | } |
95 | 100 | } |
96 | 101 |
|
97 | | - #[allow(non_upper_case_globals)] |
98 | | - static custom_error: &'static OnceGlobalRef = { |
99 | | - static custom_error: OnceGlobalRef = OnceGlobalRef::new(); |
100 | | - &custom_error |
101 | | - }; |
102 | | - |
103 | 102 | #[defun(mod_in_name = false, name = "error:signal-custom")] |
104 | 103 | fn signal_custom(env: &Env) -> Result<()> { |
105 | | - env.signal(custom_error, []) |
| 104 | + env.signal(emacs_module_rs_test_error, []) |
106 | 105 | } |
107 | 106 |
|
108 | | - env.define_error( |
109 | | - custom_error.init_to_symbol(env, "emacs-module-rs-test-error")?, |
110 | | - "Hello", |
111 | | - [env.intern("rust-error")?] |
112 | | - )?; |
113 | | - |
114 | 107 | Ok(()) |
115 | 108 | } |
0 commit comments