Spaces:
Paused
Paused
File size: 1,844 Bytes
882796d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | package error
import "net/http"
// CommonError struct
type CommonError struct {
Code int `json:"code"`
ResponseCode int `json:"responseCode,omitempty"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
// BadRequest struct
type BadRequest struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
// NewBadRequest
func NewBadRequest() BadRequest {
errObj := BadRequest{}
errObj.Message = "Bad Request"
errObj.Code = http.StatusBadRequest
return errObj
}
// NotFound struct
type NotFound struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func NewNotFound() NotFound {
errObj := NotFound{}
errObj.Message = "NotFound"
errObj.Code = http.StatusNotFound
return errObj
}
// Unauthorized struct
type Unauthorized struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func NewUnauthorized() Unauthorized {
errObj := Unauthorized{}
errObj.Message = "Unauthorized"
errObj.Code = http.StatusUnauthorized
return errObj
}
// Conflict struct
type Conflict struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func NewConflict() Conflict {
errObj := Conflict{}
errObj.Message = "Conflict"
errObj.Code = http.StatusConflict
return errObj
}
// InternalServerError struct
type InternalServerError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func NewInternalServerError() InternalServerError {
errObj := InternalServerError{}
errObj.Message = "Internal Server Error"
errObj.Code = http.StatusInternalServerError
return errObj
}
|