fix(ci): include skin site API error details in failures
This commit is contained in:
1 parent
be3a1eda8c
commit
f81a588dc1
2 files changed
+17
-2
No files matched your search
@@ -57,12 +57,14 @@ export async function publishSkinSite({
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
await response.body?.cancel()
|
const details = await response.json().catch(() => null)
|
||||||
if ((response.status === 429 || response.status >= 500) && attempt + 1 < attempts) {
|
if ((response.status === 429 || response.status >= 500) && attempt + 1 < attempts) {
|
||||||
await sleep(500 * (attempt + 1))
|
await sleep(500 * (attempt + 1))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
throw new Error(`Skin site ${route}: HTTP ${response.status}`)
|
throw new Error(
|
||||||
|
`Skin site ${route}: HTTP ${response.status}${typeof details?.errorMessage === 'string' ? ` - ${details.errorMessage.slice(0, 1000)}` : ''}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
let result
|
let result
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -170,3 +170,16 @@ test('CLI emits a GitHub error and exits nonzero when credentials are missing',
|
|||||||
assert.equal(result.status, 1)
|
assert.equal(result.status, 1)
|
||||||
assert.match(result.stderr, /::error::.*SKIN_SITE_CI_UPLOAD_TOKEN/)
|
assert.match(result.stderr, /::error::.*SKIN_SITE_CI_UPLOAD_TOKEN/)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('reports structured server errors when creating the upload session fails', async (t) => {
|
||||||
|
const { archivePath } = await fixture(t)
|
||||||
|
await assert.rejects(
|
||||||
|
publishSkinSite(
|
||||||
|
settings(archivePath, {
|
||||||
|
fetch: async () =>
|
||||||
|
Response.json({ errorMessage: 'Upload storage unavailable' }, { status: 500 }),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
/HTTP 500 - Upload storage unavailable/,
|
||||||
|
)
|
||||||
|
})
|
||||||
Reference in new issue
Block a user