Skip to content

Commit 073ceec

Browse files
Itai GendlerItai Gendler
authored andcommitted
fix print of errors 401/403
1 parent e8120eb commit 073ceec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/logic/api/helper.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const fs = require('fs');
33
const path = require('path');
44
const rp = require('request-promise');
55
const _ = require('lodash');
6+
const CFError = require('cf-errors');
67
const { printError } = require('../../interface/cli/helpers/general');
78

89
const { version } = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../../package.json')));
@@ -33,11 +34,17 @@ const sendHttpRequest = async (httpOptions, authContext) => {
3334
response = await rp(finalOptions);
3435
} catch (err) {
3536
if (_.isEqual(err.statusCode, 401)) {
36-
printError('Error: Please create or update your authentication context');
37+
printError(new CFError({
38+
cause: err,
39+
message: 'Error: Please create or update your authentication context'
40+
}));
3741
process.exit(1);
3842
}
3943
if (_.isEqual(err.statusCode, 403)) {
40-
printError('Error: You do not have permissions to perform this action');
44+
printError(new CFError({
45+
cause: err,
46+
message: 'Error: You do not have permissions to perform this action'
47+
}));
4148
process.exit(1);
4249
}
4350

0 commit comments

Comments
 (0)