Skip to content

Commit

Permalink
implement the Unwrap method for error types
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Aug 11, 2024
1 parent 5dc300a commit c30b2c5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ func (e RequestError) Type() ErrorType {
return e.cloudflareError.Type
}

func (e RequestError) Unwrap() error {
return e.cloudflareError
}

func NewRequestError(e *Error) RequestError {
return RequestError{
cloudflareError: e,
Expand Down Expand Up @@ -192,6 +196,10 @@ func (e RatelimitError) Type() ErrorType {
return e.cloudflareError.Type
}

func (e RatelimitError) Unwrap() error {
return e.cloudflareError
}

func NewRatelimitError(e *Error) RatelimitError {
return RatelimitError{
cloudflareError: e,
Expand Down Expand Up @@ -231,6 +239,10 @@ func (e ServiceError) Type() ErrorType {
return e.cloudflareError.Type
}

func (e ServiceError) Unwrap() error {
return e.cloudflareError
}

func NewServiceError(e *Error) ServiceError {
return ServiceError{
cloudflareError: e,
Expand Down Expand Up @@ -270,6 +282,10 @@ func (e AuthenticationError) Type() ErrorType {
return e.cloudflareError.Type
}

func (e AuthenticationError) Unwrap() error {
return e.cloudflareError
}

func NewAuthenticationError(e *Error) AuthenticationError {
return AuthenticationError{
cloudflareError: e,
Expand Down Expand Up @@ -309,6 +325,10 @@ func (e AuthorizationError) Type() ErrorType {
return e.cloudflareError.Type
}

func (e AuthorizationError) Unwrap() error {
return e.cloudflareError
}

func NewAuthorizationError(e *Error) AuthorizationError {
return AuthorizationError{
cloudflareError: e,
Expand Down Expand Up @@ -348,6 +368,10 @@ func (e NotFoundError) Type() ErrorType {
return e.cloudflareError.Type
}

func (e NotFoundError) Unwrap() error {
return e.cloudflareError
}

func NewNotFoundError(e *Error) NotFoundError {
return NotFoundError{
cloudflareError: e,
Expand Down

0 comments on commit c30b2c5

Please sign in to comment.