From 2aea4150a0d707c4e4926ac4a7fdbbaf0e2dfd0b Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Sat, 10 Jun 2023 21:53:30 +0200 Subject: [PATCH] improve error message --- src/bin/build.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/bin/build.ts b/src/bin/build.ts index 7271485757..87508fa089 100755 --- a/src/bin/build.ts +++ b/src/bin/build.ts @@ -2,15 +2,12 @@ /* eslint-disable global-require */ import webpack from 'webpack'; import getWebpackProdConfig from '../webpack/getProdConfig'; -import findConfig from '../config/find'; import loadConfig from '../config/load'; -const rawConfigPath = findConfig(); - export const build = async (): Promise => { - try { - const config = await loadConfig(); + const config = await loadConfig(); // Will throw its own error if it fails + try { const webpackProdConfig = getWebpackProdConfig(config); webpack(webpackProdConfig, (err, stats) => { // Stats Object @@ -29,7 +26,7 @@ export const build = async (): Promise => { }); } catch (err) { console.error(err); - throw new Error(`Error: can't find the configuration file located at ${rawConfigPath}.`); + throw new Error('Error: there was an error building the webpack config.'); } };