Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[plugin,webhook]: Add support for custom error responses #1466

Merged
merged 1 commit into from
Feb 21, 2021

Conversation

satterly
Copy link
Member

@satterly satterly commented Feb 21, 2021

Example

    def take_action(self, alert, action, text, **kwargs):
        if 'action' != 'tea':
            raise AlertaException("I'm a teapot", code=418,
                                  errors=[
                                      'server refuses to brew coffee because it is, permanently, a teapot',
                                      'See https://tools.ietf.org/html/rfc2324'
                                  ])
        return alert, action, text

Output of the above

{
  "code": 418,
  "errors": [
    "server refuses to brew coffee because it is, permanently, a teapot",
    "See https://tools.ietf.org/html/rfc2324"
  ],
  "message":"I\'m a teapot",
  "requestId": "a9d963ba-5ec0-40a4-88a6-84c33381384a",
  "status": "error"
}

References
https://tools.ietf.org/html/rfc2324

@satterly satterly force-pushed the custom-error-response branch 2 times, most recently from 7695c70 to 0b60d67 Compare February 21, 2021 19:53
@satterly satterly merged commit f240f80 into master Feb 21, 2021
saivarunr pushed a commit to rudderlabs/alerta that referenced this pull request Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant