Skip to content

Commit

Permalink
Return httpStatus in the error object.
Browse files Browse the repository at this point in the history
  • Loading branch information
vprintempsPei committed Nov 6, 2024
1 parent 6d02992 commit c58a7bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/wfs/endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ describe('WfsEndpoint', () => {
endpoint = new WfsEndpoint('https://my.test.service/ogc/wms');
});
it('rejects when the endpoint returns an exception report', async () => {
await expect(endpoint.isReady()).rejects.toThrow(
'msWFSDispatch(): WFS server error. WFS request not enabled. Check wfs/ows_enable_request settings.'
);
await expect(endpoint.isReady()).rejects.toMatchObject({
message: 'msWFSDispatch(): WFS server error. WFS request not enabled. Check wfs/ows_enable_request settings.'
});
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/wms/endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ describe('WmsEndpoint', () => {
endpoint = new WmsEndpoint('https://my.test.service/ogc/wfs');
});
it('rejects when the endpoint returns an exception report', async () => {
await expect(endpoint.isReady()).rejects.toThrow(
'msWMSGetCapabilities(): WMS server error. WMS request not enabled. Check wms/ows_enable_request settings.'
);
await expect(endpoint.isReady()).rejects.toMatchObject({
message: 'msWMSGetCapabilities(): WMS server error. WMS request not enabled. Check wms/ows_enable_request settings.',
});
});
});
});
Expand Down
10 changes: 8 additions & 2 deletions src/worker/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getUniqueId } from '../shared/id.js';
import { EndpointError } from '../shared/errors.js'

type TaskParams = Record<string, unknown>;
type TaskResponse = Record<string, unknown>;
Expand Down Expand Up @@ -76,11 +77,16 @@ export function addTaskHandler(

const eventHandler = async (request: WorkerRequest) => {
if (request.taskName === taskName) {
let response, error;
let response;
let error: EndpointError;
try {
response = await handler(request.params);
} catch (e) {
error = e;
error = {
httpStatus: e.httpStatus,
message: e.message,
name: e.name
};
}
const message = /** @type {WorkerResponse} */ {
taskName,
Expand Down

0 comments on commit c58a7bc

Please sign in to comment.