Refactored Errors

This commit is contained in:
Wyatt Johnson
2018-04-10 16:51:07 -06:00
parent 46078117c8
commit f1b8d71cba
35 changed files with 436 additions and 319 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
const { SEARCH_OTHER_USERS } = require('../../../perms/constants');
const errors = require('../../../errors');
const { ErrNotFound, ErrAlreadyExists } = require('../../../errors');
const pluralize = require('pluralize');
const sc = require('snake-case');
const CommentModel = require('../../../models/comment');
@@ -192,7 +192,7 @@ function getReactionConfig(reaction) {
) => {
const comment = await Comments.get.load(item_id);
if (!comment) {
throw errors.ErrNotFound;
throw new ErrNotFound();
}
try {
@@ -211,7 +211,7 @@ function getReactionConfig(reaction) {
[reaction]: action,
};
} catch (err) {
if (err instanceof errors.ErrAlreadyExists) {
if (err instanceof ErrAlreadyExists) {
return err.metadata.existing;
}