Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic error cdi; COUNTRY=jordan #1259

Merged
merged 10 commits into from
Jul 3, 2024
1 change: 1 addition & 0 deletions frontend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
entrypoint: yarn start
environment:
- REACT_APP_COUNTRY
- REACT_APP_USE_LOCAL_HIP_SERVICE=http://localhost:3001/q_multi_geojson
ports:
- "3000:3000"
volumes:
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/context/layers/composite_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export const fetchCompositeLayerData: LazyLoader<CompositeLayerProps> = () => as
const endDate = new Date(startDate);
endDate.setMonth(endDate.getMonth() + 1);

const { baseUrl, inputLayers, startDate: areaStartDate } = layer;
const { baseUrl: _baseUrl, inputLayers, startDate: areaStartDate } = layer;
const baseUrl = process.env.REACT_APP_USE_LOCAL_HIP_SERVICE
? process.env.REACT_APP_USE_LOCAL_HIP_SERVICE
: _baseUrl;
const { boundingBox } = appConfig.map;

// docs: https://hip-service.ovio.org/docs#/default/run_q_multi_geojson_q_multi_geojson_post
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/utils/error-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export class HTTPError extends Error {
constructor(
public readonly message: string,
public readonly statusCode: number,
public readonly detail?: string,
) {
super(message);
console.error('New HTTP Error: ', { message, statusCode, detail });
}
}
6 changes: 5 additions & 1 deletion frontend/src/utils/fetch-with-timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ export const fetchWithTimeout = async (
signal: controller.signal,
});
if (!res.ok) {
const body = await res.json();
throw new HTTPError(
fetchErrorMessage ?? `Something went wrong requesting at ${resource}`,
body.detail ??
fetchErrorMessage ??
`Something went wrong requesting at ${resource}`,
res.status,
body,
);
}
return res;
Expand Down
Loading