2018-04-22 20:39:22 +03:00
|
|
|
package errs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Error returns the string representation of the error and satisfies the error interface.
|
|
|
|
func (f *Failure) Error() string {
|
|
|
|
return f.RuntimeErr.Error()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ApiError returns formatted string representation of the API error
|
|
|
|
func (f *Failure) ApiError() string {
|
2018-10-18 18:21:07 +03:00
|
|
|
return fmt.Sprintf("%+v", f.ApiErr)
|
2018-04-22 20:39:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// ApiErrors returns array of formatted strings that represents API errors
|
2018-10-18 18:21:07 +03:00
|
|
|
func (f *Failure) ApiErrors() interface{} {
|
2018-04-23 16:28:54 +03:00
|
|
|
return f.ApiErrs
|
2018-04-22 20:39:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// ErrorResponse method
|
|
|
|
func ErrorResponse(data []byte) (FailureResponse, error) {
|
|
|
|
var resp FailureResponse
|
|
|
|
err := json.Unmarshal(data, &resp)
|
|
|
|
|
|
|
|
return resp, err
|
|
|
|
}
|