File tree 2 files changed +14
-9
lines changed
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 2
2
name = " err-rs"
3
3
version = " 0.1.0"
4
4
edition = " 2021"
5
-
6
- # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
-
8
- [dependencies ]
Original file line number Diff line number Diff line change 1
- // Copyright 2024 LangVM Project
2
- // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0
3
- // that can be found in the LICENSE file and https://mozilla.org/MPL/2.0/.
1
+ // Copyright 2024 Jelly Terra
2
+ // Use of this source code form is governed under the MIT license.
4
3
5
4
#[ macro_export]
6
5
macro_rules! err {
@@ -23,8 +22,18 @@ macro_rules! ok {
23
22
macro_rules! wrap_result {
24
23
( $tag: expr, $expr: expr) => {
25
24
match $expr {
26
- Ok ( v) => { v }
27
- Err ( e) => { return Err ( $tag( e) ) ; }
25
+ Ok ( v) => v,
26
+ Err ( e) => err!( $tag, e)
27
+ }
28
+ } ;
29
+ }
30
+
31
+ #[ macro_export]
32
+ macro_rules! on_err {
33
+ ( $expr: expr, $err_name: ident => $err_handle: expr) => {
34
+ match $expr {
35
+ Ok ( v) => v,
36
+ Err ( $err_name) => $err_handle
28
37
}
29
38
} ;
30
39
}
You can’t perform that action at this time.
0 commit comments