Skip to content

Rework error responses #12

Description

@tm1000

Right now in my own usage of shippy I get errors such as:

400 Client error: `POST https://apis.fedex.com/rate/v1/rates/quotes` resulted in a `400 Bad Request` response:
{"transactionId":"..snipped..","errors":[{"code":"CURRENCY.TYPE.SELECT","message":"Please enter Currency","parameterList":[{"key":"COMMODITY_INDEX","value":"1"}]}]}

This is returned from getErrors() as a string representation of a guzzle exxception error here:

$data['__errors'][] = "{$response->getStatusCode()} {$response->getErrorMessage()}";

I'm not a super fan of turning exceptions into strings to later be returned because there can be valuable information in the exception that can be retrieved later. Instead of it being a string could we instead send the exception as is into errors? I haven't looked into why shippy stringifys these exceptions

Would you accept a PR that changes how this functions/works? __toString() is a method on all Exceptions so in the end it could still be a string it would just allow better visibility into the exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions