Skip to content

Return more useful errors #4

@cbetta

Description

@cbetta

In the ruby library I've tried to catch most errors and bubble them up in a meaningful way. For example when I send a fax to a number that I'm not yet allowed to send a fax to I get:

fax = interfax.deliver(faxNumber: "+11111111112", file: 'spec/test.pdf')

InterFAX::Client::BadRequestError: Bad request (400): {"code":-111,"message":"Attempting to fax to a number that is not the designated fax number in a developer account","moreInfo":null}

In this library I get

>>> fax = interfax.deliver(fax_number="+442084978650", files=["tests/test.pdf"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "interfax/outbound.py", line 20, in deliver
    files=self._generate_files(files))
  File "interfax/client.py", line 76, in post
    return self._request('POST', url, **kwargs)
  File "interfax/client.py", line 89, in _request
    return self._parse_response(request(method, url, **kwargs))
  File "interfax/client.py", line 117, in _parse_response
    response.raise_for_status()
  File "/Users/cbetta/.pyenv/versions/2.7.12/lib/python2.7/site-packages/requests/models.py", line 862, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://rest.interfax.net/outbound/faxes?faxNumber=%2B442084978650

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