Giter VIP home page Giter VIP logo

fl33t-client's People

Contributors

fl33t-code avatar jnhmcknight avatar jperras avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fl33t-client's Issues

Logger is a bit aggressive on 4xx level responses from API.

I have a few situations where I perform the equivalent of a create-or-get operation, e.g.

try:
    device = fleet.create_device(device_id='foobar', name='My Great Device', fleet_id='xxx')
except DuplicateDeviceIdError:
    device = fleet.service.get_device(device_id='foobar')

which works as expected. However, even though I capture and handle the DuplicateDeviceIdError, an exception log is emitted:

409 Client Error: Conflict for url: https://api.fl33t.com/team/<teamid>/device
Traceback (most recent call last):
  File "[…redacted…]/lib/python3.6/site-packages/fl33t/client.py", line 275, in _request
    result.raise_for_status()
  File "[…redacted…]/lib/python3.6/site-packages/requests/models.py", line 939, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 409 Client Error: Conflict for url: https://api.fl33t.com/team/<teamid>/device

This was confusing, since the operation succeeded (from my point of view), but there was still an exception log generated.

The pertinent section in the code is: https://github.com/fictivekin/fl33t-client/blob/2cc44267bb7e3919fd71f46ebc8772c4d439be74/fl33t/client.py#L273-L287

Where if an HTTPError is raised from requests, it is unconditionally logged. This affects the device creation logic: https://github.com/fictivekin/fl33t-client/blob/2cc44267bb7e3919fd71f46ebc8772c4d439be74/fl33t/models/device.py#L134-L136

in that the log is emitted, and the DuplicateDeviceIdError exception is raised.

I propose that exceptions are logged only if they are not explicitly re-raised as a different, client-specific exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.