error processing updated
This commit is contained in:
parent
d99e197d4b
commit
404a1a9a61
22
api.go
22
api.go
|
@ -26,6 +26,18 @@ func (e MlflowApiError) Error() string {
|
|||
return fmt.Sprint("Request Error " + string(e.ErrorCode) + ": " + e.ErrorDesc)
|
||||
}
|
||||
|
||||
type MlflowApiErrorNotFound MlflowApiError
|
||||
|
||||
func (e MlflowApiErrorNotFound) Error() string {
|
||||
return fmt.Sprint("Request Error 404 " + string(e.ErrorCode) + ": " + e.ErrorDesc)
|
||||
}
|
||||
|
||||
type MlflowApiError400 MlflowApiError
|
||||
|
||||
func (e MlflowApiError400) Error() string {
|
||||
return fmt.Sprint("Request Error 400 " + string(e.ErrorCode) + ": " + e.ErrorDesc)
|
||||
}
|
||||
|
||||
type Timestamp int64
|
||||
|
||||
func (t *Timestamp) Time() time.Time {
|
||||
|
@ -67,7 +79,15 @@ func apiReadReply(resp *http.Response, err error, ref any) error {
|
|||
fmt.Println("Error when parsing reply: ", err2.Error(), "\n", string(body))
|
||||
return err2
|
||||
}
|
||||
return err
|
||||
|
||||
switch resp.StatusCode {
|
||||
case 400:
|
||||
return MlflowApiError400(err)
|
||||
case 404:
|
||||
return MlflowApiErrorNotFound(err)
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = json.Unmarshal(body, &ref)
|
||||
|
|
Loading…
Reference in New Issue