Skip to content

Commit

Permalink
Ensure proper standard errors are being set
Browse files Browse the repository at this point in the history
Let's ensure we never have a throw that isn't at least a standard
generic error code.
  • Loading branch information
surminus committed Aug 25, 2023
1 parent a658ec9 commit 33bb373
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ class Space extends EventEmitter<SpaceEventsMap> {
const self = await this.members.getSelf();

if (!isObject(profileDataOrUpdateFn) && !isFunction(profileDataOrUpdateFn)) {
throw new Error('Space.updateProfileData(): Invalid arguments: ' + inspect([profileDataOrUpdateFn]));
throw new InvalidArgumentError(
'Space.updateProfileData(): Invalid arguments: ' + inspect([profileDataOrUpdateFn]),
);
}

const update = {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export default class EventEmitter<T extends EventMap> {
const eventThis = { event: targetState };

if (typeof targetState !== 'string' || typeof currentState !== 'string') {
throw 'whenState requires a valid event String argument';
throw new InvalidArgumentError('whenState requires a valid event String argument');
}
if (typeof listener !== 'function' && Promise) {
return new Promise((resolve) => {
Expand Down

0 comments on commit 33bb373

Please sign in to comment.