Skip to content

Commit

Permalink
fix: improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVolland committed Sep 13, 2024
1 parent 9003ba7 commit 1c5b576
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async function main() {
// Check source path arg.
if (!sourcePath) {
indicator.fail('No input file or folder specified.');
return;
return Promise.reject('No input file or folder specified.');
}

// Check source exists, is a dir or a file ?
Expand All @@ -274,12 +274,11 @@ async function main() {
// Try to define type of target (file or dir).
// Assume the target is the same as the source
let targetIsFile = sourceIsFile;
const outputExists = existsSync(outputPath);

// Dir to file is not possible
if (!sourceIsFile && targetIsFile) {
indicator.fail('The source is a directory, so the target must be directory, too.');
return;
return Promise.reject('The source is a directory, so the target must be directory, too.');
}

// Get source and target parser.
Expand All @@ -288,7 +287,7 @@ async function main() {
const targetParser = targetFormat && getParserFromFormat(targetFormat) || getParserFromFilename(outputPath);
if (!sourceParser) {
indicator.fail('No sourceparser was specified.');
return;
return Promise.reject('No sourceparser was specified.');
}
if (!targetParser) {
indicator.info('No targetparser was specified. Output will be a GeoStyler object.');
Expand Down

0 comments on commit 1c5b576

Please sign in to comment.