Skip to content

Commit

Permalink
Split file
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 5, 2022
1 parent 835d273 commit 8a516a3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/config/normalize/lib/error.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createErrorType } from '../../../error/utils.js'
import { createErrorType } from '../../../error/create.js'

// Invalid `inputs`
export const InputError = createErrorType('InputError')
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin/lib/error.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createErrorType } from '../../../error/utils.js'
import { createErrorType } from '../../../error/create.js'

// Error from the library
export const CoreError = createErrorType('CoreError')
Expand Down
10 changes: 10 additions & 0 deletions src/error/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Create an error type with a specific `name`
export const createErrorType = function (name) {
return class extends Error {
constructor(message, opts) {
super(message, opts)
// eslint-disable-next-line fp/no-this, fp/no-mutation
this.name = name
}
}
}
2 changes: 1 addition & 1 deletion src/error/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createErrorType } from './utils.js'
import { createErrorType } from './create.js'

// Bug in the library itself
export const CoreError = createErrorType('CoreError')
Expand Down
11 changes: 0 additions & 11 deletions src/error/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,3 @@
export const normalizeError = function (error) {
return error instanceof Error ? error : new Error(error)
}

// Create an error type with a specific `name`
export const createErrorType = function (name) {
return class extends Error {
constructor(message, opts) {
super(message, opts)
// eslint-disable-next-line fp/no-this, fp/no-mutation
this.name = name
}
}
}
2 changes: 1 addition & 1 deletion src/runners/common/error.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createErrorType } from '../../error/create.js'
import { allowErrorTypes } from '../../error/types.js'
import { createErrorType } from '../../error/utils.js'

// Error from the library itself
export const CoreError = createErrorType('CoreError')
Expand Down

0 comments on commit 8a516a3

Please sign in to comment.