Skip to content

Throw more readable HTTP error.Β #58

@NeroBlackstone

Description

@NeroBlackstone

For now, the MLFlowClient.jl simply throw out HTTP.Exceptions.StatusError or use hard code error message, and this is hard to figuar out what is wrong.

I found that for any 4xx and 5xx JSON response, it will give a error message:

{
    "error_code": "RESOURCE_DOES_NOT_EXIST",
    "message": "Could not find experiment with ID 0004"
}

So, why not parse and throw this error message , rather than manually hard code error message like:

 catch e
        if isa(e, HTTP.ExceptionRequest.StatusError) && e.status == 400
            error_code = JSON.parse(String(e.response.body))["error_code"]
           # if error_code == MLFLOW_ERROR_CODES.RESOURCE_ALREADY_EXISTS
           #     error("Experiment with name \"$name\" already exists")
           #end
           error_message = JSON.parse(String(e.response.body))["error_message"]
           error(error_message)
        end
        throw(e)
    end

We can add a unified error handler, if you think this is useful I can implement it and open a pull request!

Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions