refactor: Print cause chain when downcasting AnyError fails (#9059)

This commit is contained in:
Bert Belder 2021-01-08 16:57:37 -08:00 committed by GitHub
parent 9cf82d3c66
commit f3ead9c6a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -32,6 +32,12 @@ pub(crate) fn get_error_class_name(e: &AnyError) -> &'static str {
.map(get_diagnostic_class)
})
.unwrap_or_else(|| {
panic!("Error '{}' contains boxed error of unknown type", e);
panic!(
"Error '{}' contains boxed error of unknown type:{}",
e,
e.chain()
.map(|e| format!("\n {:?}", e))
.collect::<String>()
);
})
}

View file

@ -201,6 +201,12 @@ pub async fn run(
fn get_error_class_name(e: &AnyError) -> &'static str {
deno_runtime::errors::get_error_class_name(e).unwrap_or_else(|| {
panic!("Error '{}' contains boxed error of unknown type", e);
panic!(
"Error '{}' contains boxed error of unsupported type:{}",
e,
e.chain()
.map(|e| format!("\n {:?}", e))
.collect::<String>()
);
})
}