-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor fixes for webhooks package & project creation (#105)
* Add new errors file in webhooks package * Webhook errors are now wrapped as WebhookErrors * This is for better error handling * Set numRetries to default to 3 * Set retry error to last error only
- Loading branch information
Showing
4 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package webhooks | ||
|
||
import "fmt" | ||
|
||
type WebhookError struct { | ||
msg string | ||
err error | ||
} | ||
|
||
func NewWebhookError(err error) *WebhookError { | ||
return &WebhookError{ | ||
msg: "error invoking webhook", | ||
err: err, | ||
} | ||
} | ||
|
||
// Implement errors.Error method | ||
func (e *WebhookError) Error() string { | ||
return fmt.Sprintf("%s: %v", e.msg, e.err) | ||
} | ||
|
||
func (e *WebhookError) Unwrap() error { | ||
return e.err | ||
} | ||
|
||
func (e *WebhookError) Is(target error) bool { | ||
_, ok := target.(*WebhookError) | ||
return ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters