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

Create webhook verification custom exceptions #177

Merged
merged 1 commit into from
Sep 23, 2024

Conversation

gcsuk
Copy link
Contributor

@gcsuk gcsuk commented Sep 11, 2024

Description

When calling VerifyHeader it would be good to know the difference between verification exceptions and any other possible exception. Currently, generic Exceptions are thrown, if we change this to custom exceptions they can be caught and handled specifically.

After this change we can do:

 try
 {
    ...
    webhookService.VerifyHeader(body, header, secret, 300);
    ....
 }
 catch (WorkOSWebhookException ex)
 {
     // Handle webhook exception
 }
catch (Exception ex)
{
    // Other exception handling
}

This is a non-breaking change as the custom exception inherits Exception, so any existing consumer handling these will still catch them.

Fixes #176

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@gcsuk gcsuk requested a review from a team as a code owner September 11, 2024 20:36
@gcsuk gcsuk requested a review from PaulAsjes September 11, 2024 20:36
@BoatPartyJesus
Copy link

This would actually be useful for us too for the additional context that comes with specific exceptions

Copy link
Contributor

@gcarvelli gcarvelli left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the contribution!

@gcarvelli gcarvelli merged commit f7f936c into workos:main Sep 23, 2024
3 checks passed
@gcarvelli gcarvelli mentioned this pull request Sep 23, 2024
@gcarvelli
Copy link
Contributor

This has been released in WorkOS.net version 2.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Exception improvements for Webhook header verification
3 participants