Skip to content

Commit f312d2f

Browse files
committed
Enhance error handling in main.ts to include status text and full response details; update tests to reflect new error message format. Update coverage badge to reflect 99.02% coverage.
1 parent 02a429a commit f312d2f

5 files changed

Lines changed: 32 additions & 8 deletions

File tree

__tests__/main.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,17 @@ describe('main.ts', () => {
322322
mockFetch.mockResolvedValue({
323323
ok: false,
324324
status: 500,
325-
text: async () => 'Internal server error'
325+
statusText: 'Internal Server Error',
326+
text: async () => 'Internal server error',
327+
headers: new Map([['content-type', 'application/json']])
326328
})
327329

328330
await run()
329331

330332
expect(core.warning).toHaveBeenCalledWith(
331-
'Proxy error 500: Internal server error'
333+
expect.stringContaining(
334+
'Proxy error 500 Internal Server Error: Internal server error'
335+
)
332336
)
333337
expect(core.setFailed).not.toHaveBeenCalled()
334338
})
@@ -342,13 +346,17 @@ describe('main.ts', () => {
342346
mockFetch.mockResolvedValue({
343347
ok: false,
344348
status: 500,
345-
text: async () => 'Internal server error'
349+
statusText: 'Internal Server Error',
350+
text: async () => 'Internal server error',
351+
headers: new Map([['content-type', 'application/json']])
346352
})
347353

348354
await run()
349355

350356
expect(core.setFailed).toHaveBeenCalledWith(
351-
'Proxy error 500: Internal server error'
357+
expect.stringContaining(
358+
'Proxy error 500 Internal Server Error: Internal server error'
359+
)
352360
)
353361
})
354362

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,15 @@ export async function run(): Promise<void> {
229229

230230
debug(`API response status: ${resp.status}`)
231231
if (!resp.ok) {
232-
const msg = `Proxy error ${resp.status}: ${await resp.text()}`
232+
const errorBody = await resp.text()
233+
const errorDetails = {
234+
status: resp.status,
235+
statusText: resp.statusText,
236+
body: errorBody,
237+
headers: Object.fromEntries(resp.headers.entries())
238+
}
239+
const msg = `Proxy error ${resp.status} ${resp.statusText}: ${errorBody}\nFull response: ${JSON.stringify(errorDetails, null, 2)}`
240+
debug(`Full error response: ${JSON.stringify(errorDetails, null, 2)}`)
233241
if (failOnProxyError) {
234242
core.setFailed(msg)
235243
return

0 commit comments

Comments
 (0)