Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
@phenomic/core: better display in case of error during start/build
Browse files Browse the repository at this point in the history
  • Loading branch information
MoOx committed May 9, 2018
1 parent 1072c57 commit ef32bb0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/core/src/index.js
Expand Up @@ -8,10 +8,10 @@ import start from "./commands/start.js";
import build from "./commands/build.js";
import log from "./utils/log.js";

const shittyCatch = error => {
setTimeout(() => {
throw error;
}, 1);
const handleError = error => {
if (error.message) log.error(error.message);
if (error.stack) log.error(error.stack);
process.exit(1);
};

function normalizeConfiguration(
Expand All @@ -33,19 +33,19 @@ function normalizeConfiguration(
...(config || {})
});
})
.catch(shittyCatch);
.catch(handleError);
}

export default {
start(inputConfig?: PhenomicInputConfig) {
normalizeConfiguration(inputConfig)
.then(start)
.catch(shittyCatch);
.catch(handleError);
},
build(inputConfig?: PhenomicInputConfig) {
normalizeConfiguration(inputConfig)
.then(build)
.catch(shittyCatch);
.catch(handleError);
},
async preview(inputConfig?: PhenomicInputConfig) {
try {
Expand All @@ -59,7 +59,7 @@ export default {
port: config.port
});
} catch (e) {
shittyCatch(e);
handleError(e);
}
}
};

0 comments on commit ef32bb0

Please sign in to comment.