File tree Expand file tree Collapse file tree 5 files changed +45
-9
lines changed Expand file tree Collapse file tree 5 files changed +45
-9
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ exports.run = async function({ opts }) {
51
51
auth : { user : key } ,
52
52
} ;
53
53
54
- return request
55
- . post ( `${ config . host } /api/v1/version` , options )
56
- . catch ( err => Promise . reject ( new Error ( err ) ) ) ;
54
+ return request . post ( `${ config . host } /api/v1/version` , options ) . catch ( err => {
55
+ let errorDesc ;
56
+ try {
57
+ errorDesc = JSON . parse ( err . error ) . description ;
58
+ } catch ( e ) {
59
+ errorDesc = 'Failed to create a new version using your specified parameters.' ;
60
+ }
61
+ return Promise . reject ( new Error ( errorDesc ) ) ;
62
+ } ) ;
57
63
} ;
Original file line number Diff line number Diff line change @@ -31,5 +31,13 @@ exports.run = async function({ opts }) {
31
31
. delete ( `${ config . host } /api/v1/version/${ version } ` , {
32
32
auth : { user : key } ,
33
33
} )
34
- . catch ( err => Promise . reject ( new Error ( err ) ) ) ;
34
+ . catch ( err => {
35
+ let errorDesc ;
36
+ try {
37
+ errorDesc = JSON . parse ( err . error ) . description ;
38
+ } catch ( e ) {
39
+ errorDesc = 'Failed to delete target version.' ;
40
+ }
41
+ return Promise . reject ( new Error ( errorDesc ) ) ;
42
+ } ) ;
35
43
} ;
Original file line number Diff line number Diff line change @@ -24,5 +24,13 @@ exports.run = function({ opts }) {
24
24
json : true ,
25
25
auth : { user : key } ,
26
26
} )
27
- . catch ( err => Promise . reject ( new Error ( err ) ) ) ;
27
+ . catch ( err => {
28
+ let errorDesc ;
29
+ try {
30
+ errorDesc = JSON . parse ( err . error ) . description ;
31
+ } catch ( e ) {
32
+ errorDesc = 'Failed to get versions attached to the provided key.' ;
33
+ }
34
+ return Promise . reject ( new Error ( errorDesc ) ) ;
35
+ } ) ;
28
36
} ;
Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ exports.run = async function({ opts }) {
51
51
auth : { user : key } ,
52
52
} ;
53
53
54
- return request
55
- . put ( `${ config . host } /api/v1/version/${ version } ` , options )
56
- . catch ( err => Promise . reject ( new Error ( err ) ) ) ;
54
+ return request . put ( `${ config . host } /api/v1/version/${ version } ` , options ) . catch ( err => {
55
+ let errorDesc ;
56
+ try {
57
+ errorDesc = JSON . parse ( err . error ) . description ;
58
+ } catch ( e ) {
59
+ errorDesc = 'Failed to update version using your specified parameters.' ;
60
+ }
61
+ return Promise . reject ( new Error ( errorDesc ) ) ;
62
+ } ) ;
57
63
} ;
Original file line number Diff line number Diff line change @@ -32,5 +32,13 @@ exports.run = function({ opts }) {
32
32
json : true ,
33
33
auth : { user : key } ,
34
34
} )
35
- . catch ( err => Promise . reject ( new Error ( err ) ) ) ;
35
+ . catch ( err => {
36
+ let errorDesc ;
37
+ try {
38
+ errorDesc = JSON . parse ( err . error ) . description ;
39
+ } catch ( e ) {
40
+ errorDesc = 'Failed to get specific version using provided identifier and key.' ;
41
+ }
42
+ return Promise . reject ( new Error ( errorDesc ) ) ;
43
+ } ) ;
36
44
} ;
You can’t perform that action at this time.
0 commit comments