Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Adding generic errorHandler to proxyIntegration #60

Merged
merged 3 commits into from
Feb 24, 2021

Conversation

swaner
Copy link
Contributor

@swaner swaner commented Feb 5, 2021

fixes #41 .Adding a generic error handler. The idéa is to have a place for handling error logging and also return custom error messages. Ex:

onError: (error, event, context) => {
    // Global exceptions goes here, works for sns, s3 and sqs should end up here aswell
    console.log(error)
},
proxyIntegration: {
    onError: (error, request, context) => {
        // proxy integration exceptions goes here
        console.log('Error', error, request, context)
    },
    routes: ...
}

// Also support returning a response:
proxyIntegration: {
    onError: async (error) => {
        console.log('Error', error)
        await someAsyncMethod();
        return {
           statusCode: 401,
           body: Not allowed
        }
    },
    routes: ...
}

Copy link
Member

@chgohlke chgohlke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@chgohlke chgohlke merged commit 7f69fbd into spring-media:master Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No Custom Uncaught Error Handling
2 participants