Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/pic/src/http2-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class Http2Client {

// server encountered an error, fail immediately
if ('message' in resBody) {
throw new ServerError(resBody.message);
throw new ServerError(`${resBody.message} (${init.path})`);
}

// the server has started processing or is busy
Expand Down Expand Up @@ -149,7 +149,7 @@ export class Http2Client {

// server encountered an error, fail immediately
if ('message' in resBody) {
throw new ServerError(resBody.message);
throw new ServerError(`${resBody.message} (${init.path})`);
}
Comment thread
nikosxenakis marked this conversation as resolved.

// the server has started processing or is busy
Expand Down
14 changes: 13 additions & 1 deletion packages/pic/tests/src/util/http2-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Http2Client', () => {
const err = await client.jsonGet({ path: '/test' }).catch(e => e);

expect(err).toBeInstanceOf(ServerError);
expect(err.serverMessage).toBe('SettingTimeIntoPast');
expect(err.serverMessage).toBe('SettingTimeIntoPast (/test)');
expect(fetchMock).toHaveBeenCalledTimes(1);
});

Expand Down Expand Up @@ -134,6 +134,18 @@ describe('Http2Client', () => {
expect(fetchMock).toHaveBeenCalledTimes(2);
});

it('should throw ServerError immediately on error response', async () => {
fetchMock.mockResolvedValue(
jsonResponse({ message: 'InstanceNotFound' }),
);

const err = await client.jsonPost({ path: '/test' }).catch(e => e);

expect(err).toBeInstanceOf(ServerError);
expect(err.serverMessage).toBe('InstanceNotFound (/test)');
expect(fetchMock).toHaveBeenCalledTimes(1);
});

it('should poll read_graph on 202 until the result is ready', async () => {
fetchMock
.mockResolvedValueOnce(
Expand Down
Loading