From 168b22cd412452d2bd0b79c1bcb56f2e93319073 Mon Sep 17 00:00:00 2001 From: Johan Suleiko Allansson Date: Mon, 18 Oct 2021 16:30:40 +0200 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=C2=A0remove=20verror=20dependency=20f?= =?UTF-8?q?rom=20lib=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/har-to-k6.js | 4 ++-- src/error.js | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/har-to-k6.js b/bin/har-to-k6.js index 3c368f56..9b70fb0b 100755 --- a/bin/har-to-k6.js +++ b/bin/har-to-k6.js @@ -5,10 +5,10 @@ const convert = require('../src/convert') const fs = require('fs') const io = require('caporal') const pkginfo = require('pkginfo') -const { HarToK6Error } = require('../src/error') const { DEFAULT_CLI_OPTIONS } = require('../src/constants') +const { VError } = require('verror') -class CommandLineError extends HarToK6Error {} +class CommandLineError extends VError {} pkginfo(module, 'version') const version = module.exports.version diff --git a/src/error.js b/src/error.js index 65902b77..26da9b7b 100644 --- a/src/error.js +++ b/src/error.js @@ -1,11 +1,17 @@ -const { VError } = require('verror') +class DetailedError extends Error { + constructor(details, message) { + super(typeof details === 'string' ? details : message) -class HarToK6Error extends VError {} -class InvalidArchiveError extends HarToK6Error {} -class UnrecognizedError extends HarToK6Error {} + if (typeof details === 'object') { + Object.assign(this, details) + } + } +} + +class InvalidArchiveError extends DetailedError {} +class UnrecognizedError extends DetailedError {} module.exports = { - HarToK6Error, InvalidArchiveError, UnrecognizedError, } From 7c967184433efcfea73ab0c42af79e9f5639135e Mon Sep 17 00:00:00 2001 From: Thomas Wikman Date: Fri, 29 Oct 2021 13:51:47 +0200 Subject: [PATCH 2/2] [fix] Rename `DetailedError` to `HarToK6Error` --- src/error.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/error.js b/src/error.js index 26da9b7b..6223cd36 100644 --- a/src/error.js +++ b/src/error.js @@ -1,4 +1,4 @@ -class DetailedError extends Error { +class HarToK6Error extends Error { constructor(details, message) { super(typeof details === 'string' ? details : message) @@ -8,10 +8,11 @@ class DetailedError extends Error { } } -class InvalidArchiveError extends DetailedError {} -class UnrecognizedError extends DetailedError {} +class InvalidArchiveError extends HarToK6Error {} +class UnrecognizedError extends HarToK6Error {} module.exports = { + HarToK6Error, InvalidArchiveError, UnrecognizedError, }