Fix error handling, extend testcases, add errors to documentation

* Searched for error-codes and had to look into source code
* maybe this is useful ;)
Yeaahh but then it should be implemented In this way and not something Like
an unfinished story. ^^

Maybe i change this tomorrow.
Am 22.08.2014 15:39 schrieb "Ben Hockey" <notifications@github.com>:

> In index.js:
>
> > @@ -83,7 +83,7 @@ function JsonWebTokenError(message, error) {
> >  JsonWebTokenError.prototype = Object.create(Error.prototype);
> >  JsonWebTokenError.prototype.constructor = JsonWebTokenError;
> >
> > -var TokenExpiredError = module.exports.TokenExpiredError = function (message, expiredAt) {
>
> then maybe it should export JsonWebTokenError too.
>
> i don't know what the intent here was but to me, it looked like this code
> was heading towards having a separate error for each kind of failure - e.g.
> IssuerMismatchError, AudienceMismatchError, etc. if each of those errors
> and JsonWebTokenError were exported then code could use instanceof to
> handle those errors.
>
> for code that wanted to respond differently to each kind of error they
> could check instanceof against the specific error they wanted to handle.
> if instead, the handling code didn't care about the exact type of error but
> only wanted to distinguish between JsonWebTokenError and other kinds of
> errors then all of these errors would be instances of JsonWebTokenError
> and the code could respond one way for known JsonWebTokenError and
> another for other (unknown) errors.
>
> like i said, i don't know what the intent was but to me that was what this
> was looking like it was shaping up to be.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/auth0/node-jsonwebtoken/pull/20/files#r16597853>.
>