qooxdoo-archive / qooxdoo-cli

(deprecated, moved into qooxdoo-compiler) qx commandline
MIT License
4 stars 5 forks source link

Consistent error handling #46

Closed cboulanger closed 6 years ago

cboulanger commented 6 years ago

Sometimes we throw errors, sometimes we do process.exit() (which we shouldn't do in library classes). there should be a consistent way to handle user errors vs. application errrors.

hkollmann commented 6 years ago

What's the definition of a library in this case? Is an single command like qxcli/commands/Create a library or not? Where to handle the exit in this case? Throw an exception in all places where we now have an this.exit? And handle this in the handler with showing and process.exit(1)?

What's about shorthand process.exit(0) in publish? Throw a special exception which will end process with error Code 0?

Or allow this.exit in the command code because it's not a real library? Then we should rework the usage of process.exit to this.exit.

cboulanger commented 6 years ago

Good questions... I guess any method that can be used "from outside" as an API method should never simply exit - since it's the expectation of an API method to either return a value or throw. In any other method, for example those used by yargs, we can exit() in a controlled way.

hkollmann commented 6 years ago

OK, i prepared some cleanups. Will do a PR as soon as https://github.com/qooxdoo/qooxdoo-cli/pull/60 is merged. This avoid conflicts.

cboulanger commented 6 years ago

Fixed via #66. Thanks, @hkollmann.