caverav / auditforge

Error objects should be used as Promise rejection reasons JS-0114
Anti-pattern
Major
11 days ago11 days old
Expected the Promise rejection reason to be an Error
223          reject({ fn: 'NotFound', message: 'Vulnerability not found' });
224        else {
225          if (row.details.findIndex(d => d.locale === locale && d.title) !== -1)
226            reject({227              fn: 'BadParameters',228              message: 'Language already exists in this vulnerability',229            });230          else {
231            primeVuln = row;
232            var removeIndex = mergeVuln.details
Expected the Promise rejection reason to be an Error
220      })
221      .then(row => {
222        if (!row)
223          reject({ fn: 'NotFound', message: 'Vulnerability not found' });224        else {
225          if (row.details.findIndex(d => d.locale === locale && d.title) !== -1)
226            reject({
Expected the Promise rejection reason to be an Error
210      .exec()
211      .then(row => {
212        if (!row)
213          reject({ fn: 'NotFound', message: 'Vulnerability not found' });214        else {
215          mergeVuln = row;
216          mergeDetail = row.details.find(d => d.locale === locale);
Expected the Promise rejection reason to be an Error
189          });
190          resolve(result);
191        } else
192          reject({193            fn: 'NotFound',194            message: 'Locale with existing title not found',195          });196      })
197      .catch(err => {
198        reject(err);
Expected the Promise rejection reason to be an Error
155      .exec()
156      .then(rows => {
157        if (rows) resolve(rows);
158        else reject({ fn: 'NotFound', message: 'Vulnerability not found' });159      })
160      .catch(err => {
161        reject(err);