Created
January 4, 2017 12:56
-
-
Save asm-jaime/0a65d9675c9fbf9075a3f555660ba5aa to your computer and use it in GitHub Desktop.
Processing HTTP API errors
This file contains hidden or 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
// #################### http error {{{ | |
// ApiHttpError something | |
type ApiHttpError struct { | |
Code int `json:"errorCode"` | |
HttpCode int `json:"-"` | |
Message string `json:"errorMsg"` | |
Info string `json:"errorInfo"` | |
} | |
func (thisError *ApiHttpError) Error() string { | |
return thisError.Message | |
} | |
func NewApiHttpError(thisError error) *ApiHttpError { | |
return &ApiHttpError{0, http.StatusInternalServerError, thisError.Error(), ""} | |
} | |
var ErrUserPassEmpty = &ApiHttpError{110, http.StatusBadRequest, "Password is empty", ""} | |
var ErrUserNotFound = &ApiHttpError{123, http.StatusNotFound, "User not found", ""} | |
var ErrUserIdEmpty = &ApiHttpError{130, http.StatusBadRequest, "Empty User Id", ""} | |
var ErrUserIdWrong = &ApiHttpError{131, http.StatusBadRequest, "Wrong User Id", ""} | |
// #################### http error }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment