Skip to content

Match error handling to other runtimes #241

@rimutaka

Description

@rimutaka

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

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

  1. Log the error message, probably via error! so that it appears in CloudWatch.
  2. Serialise e into JSON instead of Debug output ({:?}).
  3. 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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions