2016-03-11 23:55:27 +00:00
|
|
|
var util = require('util');
|
2016-03-18 21:04:07 +00:00
|
|
|
var Long = require('long');
|
2016-03-11 23:55:27 +00:00
|
|
|
|
2016-03-18 21:04:07 +00:00
|
|
|
function AccessDeniedError(action, streamOrTransactionId) {
|
2016-03-11 23:55:27 +00:00
|
|
|
Error.captureStackTrace(this, this.constructor);
|
|
|
|
this.name = this.constructor.name;
|
|
|
|
this.action = action;
|
2016-03-18 21:04:07 +00:00
|
|
|
if (typeof streamOrTransactionId === 'string') {
|
|
|
|
this.message = util.format("%s access denied for stream '%s'.", action, streamOrTransactionId);
|
|
|
|
this.stream = streamOrTransactionId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Long.isLong(streamOrTransactionId)) {
|
|
|
|
this.message = util.format("%s access denied for transaction %s.", action, streamOrTransactionId);
|
|
|
|
this.transactionId = streamOrTransactionId;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
throw new TypeError("second argument must be a stream name or transaction Id.");
|
2016-03-11 23:55:27 +00:00
|
|
|
}
|
|
|
|
util.inherits(AccessDeniedError, Error);
|
|
|
|
|
|
|
|
module.exports = AccessDeniedError;
|