Skip to content

Commit 69a623f

Browse files
committed
review
1 parent 9e465e2 commit 69a623f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

crates/binding/src/lib.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ pub async fn check_oxlint(
8080
oxlint_config: String,
8181
args: utils::GlobJsArgs,
8282
) -> 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)
8584
}
8685

8786
#[napi]
@@ -90,7 +89,7 @@ pub fn check_danger_strings(
9089
args: utils::GlobJsArgs,
9190
) -> Result<Vec<check_danger_string::CheckDangerResponse>> {
9291
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)
9493
}
9594

9695
#[napi]
@@ -99,15 +98,14 @@ pub fn check_module_member_usage(
9998
args: GlobJsArgs,
10099
) -> Result<Vec<module_member_usage::ModuleMemberUsageResponse>> {
101100
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)
103102
}
104103

105104
#[napi]
106105
pub fn check_filename_case(
107106
args: utils::GlobJsArgs,
108107
) -> 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)
111109
}
112110

113111
#[napi]
@@ -116,7 +114,7 @@ pub fn check_browser_supported(
116114
args: utils::GlobJsArgs,
117115
) -> Result<Vec<check_browser_supported::CompatBox>> {
118116
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)
120118
}
121119

122120
#[napi]
@@ -128,15 +126,14 @@ pub fn check_browser_supported_with_source_code(
128126
target,
129127
source_code,
130128
)
131-
.map_err(|e| napi::Error::new(napi::Status::GenericFailure, e.to_string()))
129+
.map_err(to_napi_error)
132130
}
133131

134132
#[napi]
135133
pub fn check_syntax(
136134
args: utils::GlobJsArgs,
137135
) -> 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)
140137
}
141138

142139
// #[napi]
@@ -167,5 +164,5 @@ pub fn check_danger_jsx_props(
167164
args: utils::GlobJsArgs,
168165
) -> Result<Vec<check_danger_jsx_props::CheckDangerJsxPropsResponse>> {
169166
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)
171168
}

0 commit comments

Comments
 (0)