File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,22 +39,26 @@ async function uploadFile(url, fileContents) {
3939 method : "PUT" ,
4040 headers : { "content-type" : "" } ,
4141 } ) ;
42+
43+ if ( ! response . ok ) {
44+ // The request was made and the server responded with a status code
45+ // that falls out of the range of 2xx
46+ const error = new Error ( `HTTP error! status: ${ response . status } ` ) ;
47+ error . response = response ;
48+ throw error ;
49+ }
4250 } catch ( error ) {
4351 if ( error . response ) {
4452 // The request was made and the server responded with a status code
4553 // that falls out of the range of 2xx
4654 console . error (
4755 `File Upload Failed with Response Code: ${ error . response . status } ` ,
4856 ) ;
49- console . error ( `Error Response Body: ${ error . response . data } ` ) ;
50- } else if ( error . request ) {
51- console . error (
52- "No response received from FileStorage when uploading finding" ,
53- ) ;
54- console . error ( error ) ;
57+ const errorBody = await error . response . text ( ) ;
58+ console . error ( `Error Response Body: ${ errorBody } ` ) ;
5559 } else {
5660 // Something happened in setting up the request that triggered an Error
57- console . log ( "Error" , error . message ) ;
61+ console . error ( "Error uploading findings from hook " , error . message ) ;
5862 }
5963 process . exit ( 1 ) ;
6064 }
You can’t perform that action at this time.
0 commit comments