question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to access fault data on API requests, instead of returning `None`?

See original GitHub issue

For example the Trading API might return a negative response while creating or updating orders, see for example the error response in https://github.com/Chavithra/degiro-connector/pull/50#issuecomment-997392518

{"errors": [{"text": "Le prix renseigné (300.0500) ne respecte pas la tick size (écart minimal entre les décimales). Le prix doit être un multiple de (0.1000)."}]}

However, this is only observed in the CRITICAL Logging. The functions check_order(), confirm_order() and update_order() will return just None in case of an error.

It’s important to know what the cause of the error is. Is it for example an error with the order (such as the example above), which is refused by DeGiro? Or is it caused by a server error (HTTP Status codes) or even no internet connection (HTTP Connection error)?

This data seems already present in the underlying code of the Connector, as can be seen in the Logging messages. Would it be possible to use this in the response of the functions?

For example the standard output of these functions can be a dict with 3 parameters. Here the response of a successful request:

{
   "http_status" : 200
   "result" : True
   "error" : None
}

where result can also contain a dict, for example with the current response from check_order()

In case of a DeGiro error, it will look like:

{
   "http_status" : 200
   "result" : False
   "error" : 'Le prix renseigné (300.0500) ne respecte pas la tick size (écart minimal entre les décimales). Le prix doit être un multiple de (0.1000).'
}

In case of a Network error, it will look like:

{
   "http_status" : 500
   "result" : False
   "error" : 'The server has an internal error.'
}

This information is useful for our script, to decide what fault action to take. E.g.

  • updating an order
  • a retry
  • an abort (“call the manager” 😃)

Please let me know if this is possible.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:27 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
Delikicommented, Feb 1, 2022

My bad, will respect the process.

1reaction
Chavithracommented, Jan 31, 2022

That’s a great work @funnel20 ! Will check that in detail the following days and give you my feedback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does 'API' requests return 'None' in grequests while ...
returns None as the response (for whatever reason), grequests lets you handle that however you'd like, by calling an exception handler callback ......
Read more >
How to work with/around an API that does not return errors?
I assume there is various error handling in place. When an error occurs or null is returned, log everything in the request to...
Read more >
Best practices for API error handling and troubleshooting
Best practices for Orange API error handling and troubleshooting.
Read more >
How a RESTful API server reacts to requests - O'Reilly
Learn how to properly design RESTful APIs communication with clients, accounting for request structure, authentication, and caching.
Read more >
Using the Fetch API - MDN Web Docs
The Promise returned from fetch() won't reject on HTTP error status even if the response is an HTTP 404 or 500. Instead, as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found