Skip to content

Commit

Permalink
feat: add NewError function
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzaka Ammar committed Feb 8, 2023
1 parent 74f90f9 commit ac9ef6d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions zendesk/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ type Error struct {
resp *http.Response
}

// NewError is a function to initialize the Error type. This function will be useful
// for unit testing and mocking purposes in the client side
// to test their behavior by the API response.
func NewError(body []byte, resp *http.Response) *Error {
return &Error{
body: body,
resp: resp,
}
}

// Error the error string for this error
func (e Error) Error() string {
msg := string(e.body)
Expand Down

0 comments on commit ac9ef6d

Please sign in to comment.