| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,22 +39,26 @@ async function uploadFile(url, fileContents) { | |||
| 39 | 39 | method: "PUT", | |
| 40 | 40 | headers: { "content-type": "" }, | |
| 41 | 41 | }); | |
| 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 | + } | ||
| 42 | 50 | } catch (error) { | |
| 43 | 51 | if (error.response) { | |
| 44 | 52 | // The request was made and the server responded with a status code | |
| 45 | 53 | // that falls out of the range of 2xx | |
| 46 | 54 | console.error( | |
| 47 | 55 | `File Upload Failed with Response Code: ${error.response.status}`, | |
| 48 | 56 | ); | |
| 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}`); | ||
| 55 | 59 | } else { | |
| 56 | 60 | // 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); | ||
| 58 | 62 | } | |
| 59 | 63 | process.exit(1); | |
| 60 | 64 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments