@@ -80,8 +80,7 @@ pub async fn check_oxlint(
80
80
oxlint_config : String ,
81
81
args : utils:: GlobJsArgs ,
82
82
) -> Result < Vec < check_oxlint:: CheckOxlintResponse > > {
83
- check_oxlint:: check_oxlint ( oxlint_config, args. into ( ) )
84
- . map_err ( |e| napi:: Error :: new ( napi:: Status :: GenericFailure , e. to_string ( ) ) )
83
+ check_oxlint:: check_oxlint ( oxlint_config, args. into ( ) ) . map_err ( to_napi_error)
85
84
}
86
85
87
86
#[ napi]
@@ -90,7 +89,7 @@ pub fn check_danger_strings(
90
89
args : utils:: GlobJsArgs ,
91
90
) -> Result < Vec < check_danger_string:: CheckDangerResponse > > {
92
91
check_danger_string:: check_danger_strings ( danger_strings, args. into ( ) )
93
- . map_err ( |e| napi :: Error :: new ( napi :: Status :: GenericFailure , e . to_string ( ) ) )
92
+ . map_err ( to_napi_error )
94
93
}
95
94
96
95
#[ napi]
@@ -99,15 +98,14 @@ pub fn check_module_member_usage(
99
98
args : GlobJsArgs ,
100
99
) -> Result < Vec < module_member_usage:: ModuleMemberUsageResponse > > {
101
100
module_member_usage:: check_module_member_usage ( npm_name_vec, args. into ( ) )
102
- . map_err ( |e| napi :: Error :: new ( napi :: Status :: GenericFailure , e . to_string ( ) ) )
101
+ . map_err ( to_napi_error )
103
102
}
104
103
105
104
#[ napi]
106
105
pub fn check_filename_case (
107
106
args : utils:: GlobJsArgs ,
108
107
) -> Result < Vec < check_filename_case:: CheckFilenameCaseResponse > > {
109
- check_filename_case:: check_filename_case ( args. into ( ) )
110
- . map_err ( |e| napi:: Error :: new ( napi:: Status :: GenericFailure , e. to_string ( ) ) )
108
+ check_filename_case:: check_filename_case ( args. into ( ) ) . map_err ( to_napi_error)
111
109
}
112
110
113
111
#[ napi]
@@ -116,7 +114,7 @@ pub fn check_browser_supported(
116
114
args : utils:: GlobJsArgs ,
117
115
) -> Result < Vec < check_browser_supported:: CompatBox > > {
118
116
check_browser_supported:: check_browser_supported ( target, args. into ( ) )
119
- . map_err ( |e| napi :: Error :: new ( napi :: Status :: GenericFailure , e . to_string ( ) ) )
117
+ . map_err ( to_napi_error )
120
118
}
121
119
122
120
#[ napi]
@@ -128,15 +126,14 @@ pub fn check_browser_supported_with_source_code(
128
126
target,
129
127
source_code,
130
128
)
131
- . map_err ( |e| napi :: Error :: new ( napi :: Status :: GenericFailure , e . to_string ( ) ) )
129
+ . map_err ( to_napi_error )
132
130
}
133
131
134
132
#[ napi]
135
133
pub fn check_syntax (
136
134
args : utils:: GlobJsArgs ,
137
135
) -> Result < Vec < check_syntax:: CheckSyntaxResponse > > {
138
- check_syntax:: check_syntax ( args. into ( ) )
139
- . map_err ( |e| napi:: Error :: new ( napi:: Status :: GenericFailure , e. to_string ( ) ) )
136
+ check_syntax:: check_syntax ( args. into ( ) ) . map_err ( to_napi_error)
140
137
}
141
138
142
139
// #[napi]
@@ -167,5 +164,5 @@ pub fn check_danger_jsx_props(
167
164
args : utils:: GlobJsArgs ,
168
165
) -> Result < Vec < check_danger_jsx_props:: CheckDangerJsxPropsResponse > > {
169
166
check_danger_jsx_props:: check_danger_jsx_props ( danger_jsx_props, args. into ( ) )
170
- . map_err ( |e| napi :: Error :: new ( napi :: Status :: GenericFailure , e . to_string ( ) ) )
167
+ . map_err ( to_napi_error )
171
168
}
0 commit comments