Nicolas Dextraze
f7c13634cc
Updated uuid/webpack packages Added froze on objects publicly exposed Removed remaining while loops for actions/events processing
24 lines
860 B
JavaScript
24 lines
860 B
JavaScript
var util = require('util');
|
|
var Long = require('long');
|
|
|
|
function AccessDeniedError(action, streamOrTransactionId) {
|
|
Error.captureStackTrace(this, this.constructor);
|
|
this.name = this.constructor.name;
|
|
this.action = action;
|
|
if (typeof streamOrTransactionId === 'string') {
|
|
this.message = util.format("%s access denied for stream '%s'.", action, streamOrTransactionId);
|
|
this.stream = streamOrTransactionId;
|
|
Object.freeze(this);
|
|
return;
|
|
}
|
|
if (Long.isLong(streamOrTransactionId)) {
|
|
this.message = util.format("%s access denied for transaction %s.", action, streamOrTransactionId);
|
|
this.transactionId = streamOrTransactionId;
|
|
Object.freeze(this);
|
|
return;
|
|
}
|
|
throw new TypeError("second argument must be a stream name or transaction Id.");
|
|
}
|
|
util.inherits(AccessDeniedError, Error);
|
|
|
|
module.exports = AccessDeniedError; |