Skip to content

Commit

Permalink
Add LimitError
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 16, 2022
1 parent 96c9ece commit 97c9154
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/error/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,22 @@ export class UserError extends Error {
}
}

// eslint-disable-next-line fp/no-class
export class LimitError extends Error {
constructor(...args) {
super(...args)
// eslint-disable-next-line fp/no-this, fp/no-mutation
this.name = 'LimitError'
}
}

// Error type-specific behavior
const ERROR_PROPS = {
StopError: { exitCode: 0, printStack: false, indented: true },
CoreError: { exitCode: 1, printStack: true, indented: false },
PluginError: { exitCode: 2, printStack: true, indented: false },
UserError: { exitCode: 3, printStack: false, indented: false },
LimitError: { exitCode: 4, printStack: false, indented: false },
}

const CORE_ERROR_NAME = 'CoreError'
Expand Down
4 changes: 2 additions & 2 deletions src/history/compare/limit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCombinationName } from '../../combination/ids/name.js'
import { UserError } from '../../error/main.js'
import { LimitError } from '../../error/main.js'
import { groupBy } from '../../utils/group.js'

import { isNegativeLimit } from './parse.js'
Expand Down Expand Up @@ -36,7 +36,7 @@ export const checkLimits = function ({ combinations }) {
}

const limitErrors = getLimitErrors(limitedCombinations)
throw new UserError(limitErrors)
throw new LimitError(limitErrors)
}

const isOverLimit = function (combination) {
Expand Down

0 comments on commit 97c9154

Please sign in to comment.