|
|
|
@ -10,11 +10,11 @@ var errorsTemplate = ` |
|
|
|
|
|
|
|
|
|
func Is{{.CamelValue}}(err error) bool { |
|
|
|
|
e := errors.FromError(err) |
|
|
|
|
return e.Reason == {{.Name}}_{{.Value}}.String() && e.Code == {{.HttpCode}}
|
|
|
|
|
return e.Reason == {{.Name}}_{{.Value}}.String() && e.Code == {{.HTTPCode}}
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func Error{{.CamelValue}}(format string, args ...interface{}) *errors.Error { |
|
|
|
|
return errors.New({{.HttpCode}}, {{.Name}}_{{.Value}}.String(), fmt.Sprintf(format, args...)) |
|
|
|
|
return errors.New({{.HTTPCode}}, {{.Name}}_{{.Value}}.String(), fmt.Sprintf(format, args...)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{{- end }} |
|
|
|
@ -23,9 +23,10 @@ func Error{{.CamelValue}}(format string, args ...interface{}) *errors.Error { |
|
|
|
|
type errorInfo struct { |
|
|
|
|
Name string |
|
|
|
|
Value string |
|
|
|
|
HttpCode int |
|
|
|
|
HTTPCode int |
|
|
|
|
CamelValue string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type errorWrapper struct { |
|
|
|
|
Errors []*errorInfo |
|
|
|
|
} |
|
|
|
@ -39,5 +40,5 @@ func (e *errorWrapper) execute() string { |
|
|
|
|
if err := tmpl.Execute(buf, e); err != nil { |
|
|
|
|
panic(err) |
|
|
|
|
} |
|
|
|
|
return string(buf.Bytes()) |
|
|
|
|
return buf.String() |
|
|
|
|
} |
|
|
|
|