Pass errors in the request body

Hey there,

the guide suggests to console.log an error at the end of the: “Add a Create Note API” chapter.

Is there a specific reason (best-practices-wise) for not passing an error to the response body, like this:

catch (e) {
    return failure({ status: false, error: e });
  }

Like reducing the response load?

I found it sometimes useful in the past to have the errors right away in the dev tools, when work gets started on the frontend.

Yup you definitely can! We’ll be adding more on how to better debug Lambda functions in the future.

Just a heads up with this, sometimes you might not want to expose the error details to the client. In case it’s outputting sensitive info. Maybe only use this when in development?

1 Like