Documentation ¶
Overview ¶
Example ¶
package main import ( "encoding/json" "fmt" "net/http" "github.com/sabariramc/goserverbase/v6/errors" ) func main() { err := &errors.CustomError{"goserverbase.test.error", "test error message", "test error data", "test error description", false} fmt.Println(err) herr := errors.HTTPError{StatusCode: http.StatusConflict, CustomError: err} data, _ := json.MarshalIndent(herr, "", " ") fmt.Println(string(data)) }
Output: { "errorCode": "goserverbase.test.error", "errorMessage": "test error message", "errorData": "test error data", "errorDescription": "test error description" } { "errorCode": "goserverbase.test.error", "errorMessage": "test error message", "errorData": "test error data", "errorDescription": "test error description", "statusCode": 409 }
Index ¶
Examples ¶
Constants ¶
View Source
const ErrParse = "******************ERROR DURING MARSHAL OF FULL MESSAGE*******************"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomError ¶
type CustomError struct { ErrorCode string `json:"errorCode"` ErrorMessage string `json:"errorMessage"` ErrorData interface{} `json:"errorData"` ErrorDescription interface{} `json:"errorDescription"` Notify bool `json:"-"` }
CustomError represents a custom error with additional attributes.
func (CustomError) Error ¶
func (e CustomError) Error() string
Error returns the JSON representation of the custom error.
func (CustomError) GetErrorResponse ¶
func (e CustomError) GetErrorResponse() ([]byte, error)
GetErrorResponse returns the JSON representation of the error response.
type HTTPError ¶
type HTTPError struct { *CustomError `json:",inline"` StatusCode int `json:"statusCode"` }
HTTPError represents an HTTP error with a custom error.
Click to show internal directories.
Click to hide internal directories.