c9s / GetOptionKit

An object-oriented option parser library for PHP, which supports type constraints, flag, multiple flag, multiple values, required value checking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throw more specific exceptions

psynaptic opened this issue · comments

Great library. Thanks for your work on this.

Instead of just throwing Exception when something goes wrong, it would be more useful to throw more meaningful exceptions so they can be caught and appropriately handled.

Some examples:

MissingValueException

Uncaught exception 'Exception' with message 'Option f require a value.'

InvalidOptionException

Uncaught exception 'Exception' with message 'Invalid option: -q'

I see that there is already NonNumericException. This would just be to flesh-out the support for more specific exceptions.

commented

Yeah, totally agree, we should do that.

commented

Newly added exceptions:

  • RequireValueException
  • InvalidOptionException