-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create RequestError struct and ErrorResponse
- Pass response body of error - Remove 'unknown' error nomenclature [#167050837] Signed-off-by: Joshua Casey <[email protected]> Co-authored-by: Joshua Casey <[email protected]>
- Loading branch information
Showing
13 changed files
with
36 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,15 +1,27 @@ | ||
package uaa | ||
|
||
import "github.com/pkg/errors" | ||
import ( | ||
"fmt" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
type RequestError struct { | ||
Url string | ||
ErrorResponse []byte | ||
} | ||
|
||
func (r RequestError) Error() string { | ||
return fmt.Sprintf("An error occurred while calling %s", r.Url) | ||
} | ||
|
||
func requestErrorWithBody(url string, body []byte) error { | ||
return RequestError{url, body } | ||
} | ||
|
||
func requestError(url string) error { | ||
return errors.New("An unknown error occurred while calling " + url) | ||
return errors.Errorf("An error occurred while calling %s", url) | ||
} | ||
|
||
func parseError(err error, url string, body []byte) error { | ||
return errors.Wrapf(err, "An unknown error occurred while parsing response from %s. Response was %s", url, string(body)) | ||
} | ||
|
||
func unknownError() error { | ||
return errors.New("An unknown error occurred") | ||
} |
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