From 8a516a3f4e4137a3be86bc1e0637be2e364a6c74 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 5 Jun 2022 23:26:01 +0200 Subject: [PATCH] Split file --- src/config/normalize/lib/error.js | 2 +- src/config/plugin/lib/error.js | 2 +- src/error/create.js | 10 ++++++++++ src/error/main.js | 2 +- src/error/utils.js | 11 ----------- src/runners/common/error.js | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 src/error/create.js diff --git a/src/config/normalize/lib/error.js b/src/config/normalize/lib/error.js index b1e24d523..a417ca653 100644 --- a/src/config/normalize/lib/error.js +++ b/src/config/normalize/lib/error.js @@ -1,4 +1,4 @@ -import { createErrorType } from '../../../error/utils.js' +import { createErrorType } from '../../../error/create.js' // Invalid `inputs` export const InputError = createErrorType('InputError') diff --git a/src/config/plugin/lib/error.js b/src/config/plugin/lib/error.js index 0145e106b..8ce540c1c 100644 --- a/src/config/plugin/lib/error.js +++ b/src/config/plugin/lib/error.js @@ -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') diff --git a/src/error/create.js b/src/error/create.js new file mode 100644 index 000000000..5927d5451 --- /dev/null +++ b/src/error/create.js @@ -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 + } + } +} diff --git a/src/error/main.js b/src/error/main.js index eade1870d..9369668f5 100644 --- a/src/error/main.js +++ b/src/error/main.js @@ -1,4 +1,4 @@ -import { createErrorType } from './utils.js' +import { createErrorType } from './create.js' // Bug in the library itself export const CoreError = createErrorType('CoreError') diff --git a/src/error/utils.js b/src/error/utils.js index 2e76e08de..fabf8c398 100644 --- a/src/error/utils.js +++ b/src/error/utils.js @@ -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 - } - } -} diff --git a/src/runners/common/error.js b/src/runners/common/error.js index 168165193..dc5cf918c 100644 --- a/src/runners/common/error.js +++ b/src/runners/common/error.js @@ -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')