-
Notifications
You must be signed in to change notification settings - Fork 363
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
The format of error messages returned by the runtime is hard to work with at the client end.
Example:
{
"errorType": "alloc::boxed::Box<dyn std::error::Error+core::marker::Sync+core::marker::Send>",
"errorMessage": "LambdaError { msg: \"cust error\", source: \"somewhere in code\", code: InvalidInput }"
}
It is produced by this code in
aws-lambda-rust-runtime/lambda/src/lib.rs
Line 216 in f404617
Err(e) => EventErrorRequest { |
Err(e) => EventErrorRequest {
request_id,
diagnostic: Diagnostic {
error_message: format!("{:?}", e),
error_type: type_name_of_val(e).to_owned(),
},
}
.into_req()?,
with help from
fn type_name_of_val<T>(_: T) -> &'static str {
std::any::type_name::<T>()
}
Proposed change
- Log the error message, probably via
error!
so that it appears in CloudWatch. - Serialise
e
into JSON instead of Debug output ({:?}). - Allow to set error type and fall back on
std::any::type_name
if none was provided.
Here are examples of what other runtimes are producing:
- C#: https://docs.aws.amazon.com/lambda/latest/dg/csharp-exceptions.html
- Go: https://docs.aws.amazon.com/lambda/latest/dg/golang-exceptions.html
- Java: https://docs.aws.amazon.com/lambda/latest/dg/java-exceptions.html
- NodeJS: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-exceptions.html
Discussion
I'm not 100% sure how it all can be implemented yet. Just wondering if this is a problem that impacts others and is worth looking into.
stanislav-tkach
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request