Skip to main content

source-code_snippets_6_js

try {
// simulate an error
throw new Error("Oops! Something went wrong.");
} catch (e) {
return {
status: 418,
body: {
error: {
message: e.message,
stack: e.stack,
},
},
headers: {
"X-Custom-Header": "I am a custom header",
},
};
}