From 7771ee6057a3dd06385476814c397ab1dc63cbba Mon Sep 17 00:00:00 2001 From: Jared Hanson Date: Wed, 14 Aug 2013 16:53:08 -0700 Subject: [PATCH] Add AccessTokenError. --- lib/errors/accesstokenerror.js | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lib/errors/accesstokenerror.js diff --git a/lib/errors/accesstokenerror.js b/lib/errors/accesstokenerror.js new file mode 100644 index 0000000..cd8654d --- /dev/null +++ b/lib/errors/accesstokenerror.js @@ -0,0 +1,36 @@ +/** + * `AccessTokenError` error. + * + * AccessTokenError represents an error in response to an access token request. + * For details, refer to RFC 6749, section 5.2. + * + * References: + * - [The OAuth 2.0 Authorization Framework](http://tools.ietf.org/html/rfc6749) + * + * @constructor + * @param {String} [message] + * @param {String} [code] + * @param {String} [uri] + * @param {Number} [status] + * @api public + */ +function AccessTokenError(message, code, uri, status) { + Error.call(this); + Error.captureStackTrace(this, arguments.callee); + this.name = 'AccessTokenError'; + this.message = message; + this.code = code || 'invalid_request'; + this.uri = uri; + this.status = status || 500; +} + +/** + * Inherit from `Error`. + */ +AccessTokenError.prototype.__proto__ = Error.prototype; + + +/** + * Expose `AccessTokenError`. + */ +module.exports = AccessTokenError;