Git Product home page Git Product logo

Comments (4)

aandergr avatar aandergr commented on June 12, 2024

Yes, this would be a nice feature.

I was wondering whether there was some kind of standard or convention for how exit codes are assigned in typical unix applications, but it seems there is none except of zero being a success status and non-zero an error status. Apart of that, all tools seem to follow their arbitrary mapping of error types to exit codes.

Instaloader already distinguishes many types of errors with different exception types, it would be great to map those into return codes for the cli application. We could somehow resemble the exception tree, combined with some semantical/logical grouping of error types into the error code, e.g. by assigning a few bits to the group and the other bits to a finer granulation, as this might simplify the parsing of the exit status. So we would both have a fine granularity without making the feature less useful I think.

I could imagine something like

code Meaning
0x01 InvalidArgumentException, invalid command line arguments, --load-cookies without the library, and other failures before anything was attempted (which are currently returned with a simply SystemExit before an Instaloader instance is created)
0x10 Other connection error
0x11 Query returned "not found"
0x12 Too many requests
0x21 Query returned "bad request"
0x22 Query returned "forbidden"
0x23 Profile not exists
0x24 Private profile not followed
0x25 Login required
0x26 IPhoneSupportDisabledException
0x41 Two factor auth required
0x42 Bad credentials
0x81 User aborted (--abort-on)
0x82 User aborted (SIGINT / control+c)

So this would imply a grouping of

code & 0xf0 Meaning of group
0x00 Invalid invocation, before anything was attempted
0x10 Invocation was correct, however Instaloader failed to download
0x20 Download of the target impossible with the given invocation
0x40 Login error
0x80 User aborted

This is close to the grouping given by the exception tree, which itself was built on the way of how they must be handled internally.

However, this is only a suggestion after brief consideration. I do not want to rule out the possibility that there might be a more sensible or appropriate mapping.

from instaloader.

ekalin avatar ekalin commented on June 12, 2024

I think too many exit codes would actually add too much complexity for little benefit. If the user needs that much detail, they can use instaloader as a module and catch the actual exceptions.

[Moreover, retrofitting the exit codes in the existing code is not trivial - and the more different codes there are, the more work is necessary.]

But in addition to the general categories I had identified, some of the ones you listed can be useful:

  • Too many requests - I'd say this one deserves its own error code. However, from what I remember, if a 429 is received, the program just waits and then retries, indefinitely. It does not abort the program, unless --abort-on is used.
  • Login required - Probably useful
  • Profile does not exists / is private - Could be useful. Would be more a warning than an error, since just one of many profiles could have failed. On the on other hand, some users occasionally make their profile private (or disable them) temporarily, and I'm not sure I need to mark a instaloader run as 'failed' just because of that.

Basically your idea of groups is quite similar to my proposal, but I'm not really convinced that the level of detail provided by the lower byte is really useful. And from what I remember, some errors you listed ("bad request", "forbidden", etc) don't cause the program to terminate, just to retry or skip that item.

from instaloader.

Related Issues (20)

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.