Skip to content

Commit 9d74e98

Browse files
authored
396 - added specific error message for stopped sandbox (#397)
1 parent 5ae3691 commit 9d74e98

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

packages/b2c-tooling-sdk/src/clients/webdav.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,15 @@ export class WebDavClient {
286286
const response = await this.request(path, {method: 'PUT', headers, body: content});
287287

288288
if (!response.ok) {
289-
throw new HTTPError(`PUT failed: ${response.status} ${response.statusText}`, response, 'PUT');
289+
const hints: Record<number, string> = {
290+
413: '(sandbox may be stopped or unavailable)',
291+
};
292+
const hint = hints[response.status];
293+
throw new HTTPError(
294+
`PUT failed: ${response.status} ${response.statusText}${hint ? ` ${hint}` : ''}`,
295+
response,
296+
'PUT',
297+
);
290298
}
291299
}
292300

packages/b2c-tooling-sdk/test/clients/webdav.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,27 @@ describe('clients/webdav', () => {
269269
expect((error as HTTPError).message).to.include('507');
270270
}
271271
});
272+
273+
it('includes sandbox hint in error message on 413', async () => {
274+
server.use(
275+
http.all(`${BASE_URL}/*`, ({request}) => {
276+
if (request.method === 'PUT') {
277+
return new HttpResponse(null, {status: 413, statusText: 'Payload Too Large'});
278+
}
279+
return new HttpResponse(null, {status: 404});
280+
}),
281+
);
282+
283+
try {
284+
await client.put('Cartridges/v1/large.zip', Buffer.from('content'));
285+
expect.fail('Should have thrown');
286+
} catch (error) {
287+
expect(error).to.be.instanceOf(HTTPError);
288+
expect((error as HTTPError).message).to.include('PUT failed');
289+
expect((error as HTTPError).message).to.include('413');
290+
expect((error as HTTPError).message).to.include('sandbox may be stopped');
291+
}
292+
});
272293
});
273294

274295
describe('get', () => {

0 commit comments

Comments
 (0)