refactor: use concrete error type for remaining ops (#26746)

This commit is contained in:
Leo Kettmeir 2024-11-06 16:57:57 -08:00 committed by GitHub
parent db53ec230d
commit 1cab4f07a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1423 additions and 566 deletions

View file

@ -88,6 +88,10 @@ fn get_resolution_error_class(err: &ResolutionError) -> &'static str {
}
}
fn get_try_from_int_error_class(_: &std::num::TryFromIntError) -> &'static str {
"TypeError"
}
pub fn get_error_class_name(e: &AnyError) -> &'static str {
deno_runtime::errors::get_error_class_name(e)
.or_else(|| {
@ -106,5 +110,9 @@ pub fn get_error_class_name(e: &AnyError) -> &'static str {
e.downcast_ref::<ResolutionError>()
.map(get_resolution_error_class)
})
.or_else(|| {
e.downcast_ref::<std::num::TryFromIntError>()
.map(get_try_from_int_error_class)
})
.unwrap_or("Error")
}