Errors Standardization (#1246)

* errors and stuff

* more errors

* all the errors

* fix build
This commit is contained in:
Gus Caplan
2017-06-25 12:48:05 -05:00
committed by Amish Shah
parent 602fe06f88
commit 63e54982f4
28 changed files with 258 additions and 102 deletions

View File

@@ -1,4 +1,4 @@
const Constants = require('../util/Constants');
const { RangeError } = require('../errors');
/**
* Data structure that makes it easy to interact with a permission bitfield. All {@link GuildMember}s have a set of
@@ -95,7 +95,7 @@ class Permissions {
static resolve(permission) {
if (permission instanceof Array) return permission.map(p => this.resolve(p)).reduce((prev, p) => prev | p, 0);
if (typeof permission === 'string') permission = this.FLAGS[permission];
if (typeof permission !== 'number' || permission < 1) throw new RangeError(Constants.Errors.NOT_A_PERMISSION);
if (typeof permission !== 'number' || permission < 1) throw new RangeError('PERMISSION_INVALID');
return permission;
}
}