Skip to content

Commit e68b545

Browse files
author
nukosuke
authored
Merge pull request #256 from dzakaammar/new-error-func
feat: add NewError function
2 parents 07504b5 + ac9ef6d commit e68b545

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

zendesk/error.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ type Error struct {
1414
resp *http.Response
1515
}
1616

17+
// NewError is a function to initialize the Error type. This function will be useful
18+
// for unit testing and mocking purposes in the client side
19+
// to test their behavior by the API response.
20+
func NewError(body []byte, resp *http.Response) *Error {
21+
return &Error{
22+
body: body,
23+
resp: resp,
24+
}
25+
}
26+
1727
// Error the error string for this error
1828
func (e Error) Error() string {
1929
msg := string(e.body)

0 commit comments

Comments
 (0)