File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -70,14 +70,22 @@ module.exports = {
7070 return await axios ( $ , requestConfig ) ;
7171 } ,
7272 async getPDF ( $ , entity , id ) {
73- const companyId = this . companyId ( ) ;
74- return await this . _makeRequest ( $ , {
75- path : `company/${ companyId } /${ entity . toLowerCase ( ) } /${ id } /pdf` ,
76- headers : {
77- "Accept" : "application/pdf" ,
78- } ,
79- responseType : "stream" ,
80- } ) ;
73+ try {
74+ const companyId = this . companyId ( ) ;
75+ return await this . _makeRequest ( $ , {
76+ path : `company/${ companyId } /${ entity . toLowerCase ( ) } /${ id } /pdf` ,
77+ headers : {
78+ "Accept" : "application/pdf" ,
79+ } ,
80+ responseType : "stream" ,
81+ } ) ;
82+ } catch ( ex ) {
83+ if ( ex . response . data . statusCode === 400 ) {
84+ throw new Error ( `Request failed with status code 400. Double-check that '${ id } ' is a valid ${ entity } record ID.` ) ;
85+ } else {
86+ throw ex ;
87+ }
88+ }
8189 } ,
8290 async getRecordDetails ( entityName , id ) {
8391 const companyId = this . companyId ( ) ;
You can’t perform that action at this time.
0 commit comments