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.

Explain Error Handling

See original GitHub issue

Hi @kroitor and @xpl and all the developers of ccxt.

I’m have a few questions about error handling in ccxt. So there are ~two~ three main methods that are in the source of most exchanges for handling errors:

  • handleErrors
  • throwErrorOnException
  • request

I gather that handleErrors called in fetch and throwErrorOnException is called pretty much anywhere. However I also see some errors get thrown in request and I’m not really sure if they should be raised there.

Could someone explain how these two methods are supposed to work together. Moreover, @kroitor was talking about only parsing JSON once before but I’m not sure where this should take place. Is

All the best, frosty

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
mkutnycommented, Mar 19, 2018

I think this might be a misconception, we can’t really throw http codes away easily, because there are exchanges that will report http error codes instead of internal codes, and we really need to differentiate between them sometimes…

As I’ve got the question was about dropping http status text, not about http status code. The code is needed, indeed. The text (i.e. reason) is not used.

What I would actually do (when the flow is unified) is switch handleErrors signature to options pattern, it’d make us flexible in args. Still, as far as I remember there were some tensions on Python side.

2reactions
mkutnycommented, Mar 12, 2018

Surely it would make sense to move the logic to handleErrors for consistency?

It’s called by handleErrors anyway. Feel free to move it, although it either won’t be as concise or will parse json twice.

why is this additional logic required?

Because sometimes we expect json (and we should throw if json is not received) and sometimes we expect plaintext (and should proceed if json is not received). Alternatively, it could be something like:

try:
    json.loads(request.body)
except ValueError:
    if jsonRequired:
        raise
    else:
        pass
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Error Handling? - Definition from Techopedia
Error handling refers to the response and recovery procedures from error conditions present in a software application. In other words, it is the...
Read more >
What is Exception Handling? - SearchSoftwareQuality
Exception handling is the process of responding to unwanted or unexpected events when a computer program runs. Exception handling deals with these events...
Read more >
Exception handling - Wikipedia
In computing and computer programming, exception handling is the process of responding to the occurrence of exceptions – anomalous or exceptional conditions ......
Read more >
Definition of error handling - PCMag
Error handling refers to the routines in a program that respond to abnormal input or conditions. The quality of such routines is based...
Read more >
How to implement complete error handling? - Codegrip
Error handling is when your software is capable to counter or confiscate errors that may have been brought on by a programmer mistake...
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