Skip to content

Commit d2f4bc0

Browse files
committed
[sentry][s]: refactored commands to send error reports to Sentry - refs #321
- removed exiting with code 1 as it now happens after Sentry report is sent and happens in one place - when catching errors, 'handleError' function should be called lastly as `process.exit(1)` happens in the callback and we don't want it to exit before other scripts are executed
1 parent 9ad95f5 commit d2f4bc0

File tree

6 files changed

+5
-15
lines changed

6 files changed

+5
-15
lines changed

bin/data-cat.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const dumpIt = async (res, {sheet}={}) => {
5555
error('Provided URL is invalid')
5656
}
5757
handleError(err)
58-
process.exit(1)
5958
}
6059

6160
if (outFormat === 'ascii') { // Write to stdout

bin/data-get.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,10 @@ const run = async () => {
105105

106106
} catch (err) {
107107
stopSpinner()
108-
handleError(err)
109108
if (argv.debug) {
110109
console.log('> [debug]\n' + err.stack)
111110
}
112-
process.exit(1)
111+
handleError(err)
113112
}
114113
}
115114

@@ -135,7 +134,6 @@ const saveFileFromUrl = (url, format) => {
135134
err.message += ' or Forbidden.'
136135
}
137136
handleError(err)
138-
process.exit(1)
139137
}
140138
stream.pipe(fs.createWriteStream(destPath)).on('finish', () => {
141139
resolve(destPath)

bin/data-info.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ Promise.resolve().then(async () => {
6666
}
6767
}
6868
} catch (err) {
69-
handleError(err)
7069
if (!argv._[0]) {
7170
printInfo('Running `data info` without an argument will search a `datapackage.json` file in the current working directory.')
7271
}
73-
process.exit(1)
72+
handleError(err)
7473
}
7574
})

bin/data-login.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Promise.resolve().then(async () => {
3838
out = await authenticate(apiUrl, token)
3939
} catch (err) {
4040
handleError(err)
41-
process.exit(1)
4241
}
4342
if (out.authenticated) {
4443
stopSpinner()

bin/data-push-flow.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Promise.resolve().then(async () => {
4242
out = await authenticate(apiUrl, token)
4343
} catch (err) {
4444
handleError(err)
45-
process.exit(1)
4645
}
4746
if (!out.authenticated) {
4847
info('You need to login in order to push your data. Please, use `data login` command.')
@@ -73,10 +72,9 @@ Promise.resolve().then(async () => {
7372
console.log(message + '🔗 ' + url + ' (copied to clipboard)')
7473
} catch (err) {
7574
stopSpinner()
76-
handleError(err)
7775
if (argv.debug) {
7876
console.log('> [debug]\n' + err.stack)
7977
}
80-
process.exit(1)
78+
handleError(err)
8179
}
8280
})

bin/data-push.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Promise.resolve().then(async () => {
4848
out = await authenticate(apiUrl, token)
4949
} catch (err) {
5050
handleError(err)
51-
process.exit(1)
5251
}
5352
}
5453
if (!out.authenticated) {
@@ -66,12 +65,11 @@ Promise.resolve().then(async () => {
6665
try {
6766
dataset = await Dataset.load(filePath)
6867
} catch(err){
69-
error(err.message)
7068
info("You can run:")
7169
info("'data validate' to check your data.")
7270
info("'data init' to create a datapackage.")
7371
info("'data help push' to get more info.")
74-
process.exit(1)
72+
handleError(err)
7573
}
7674
} else {
7775
dataset = await prepareDatasetFromFile(filePath)
@@ -136,11 +134,10 @@ Promise.resolve().then(async () => {
136134
console.log(message + '🔗 ' + url + copied)
137135
} catch (err) {
138136
stopSpinner()
139-
handleError(err)
140137
if (argv.debug) {
141138
console.log('> [debug]\n' + err.stack)
142139
}
143-
process.exit(1)
140+
handleError(err)
144141
}
145142
})
146143

0 commit comments

Comments
 (0)