Skip to content

Commit 1155291

Browse files
authored
Merge pull request #667 from Merit-Systems/br/specific-facilitator-failure-message
specific facilitators failed error
2 parents d81002f + 09a28f2 commit 1155291

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

packages/app/server/src/errors/http.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ export class PaymentRequiredError extends HttpError {
2121
}
2222
}
2323

24-
class MaxInFlightRequestsError extends HttpError {
25-
constructor(message: string = 'Max In Flight Requests') {
26-
super(429, message);
27-
}
28-
}
29-
3024
export class UnknownModelError extends HttpError {
3125
constructor(message: string = 'Unknown Model argument passed in') {
3226
super(400, message);
3327
}
3428
}
29+
30+
export class FacilitatorProxyError extends HttpError {
31+
constructor(
32+
message: string = 'FacilitatorProxyError - all facilitators are busy. Please retry after a few seconds.'
33+
) {
34+
super(513, message);
35+
}
36+
}

packages/app/server/src/services/facilitator/facilitatorProxy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import logger, { logMetric } from '../../logger';
99
import dotenv from 'dotenv';
1010
import { env } from '../../env';
11+
import { FacilitatorProxyError } from '../../errors/http';
1112

1213
dotenv.config();
1314

@@ -69,13 +70,11 @@ export async function facilitatorProxy<
6970
clearTimeout(timeoutId);
7071

7172
if (res.status !== 200) {
72-
const errorBody = await res.text();
73-
const errorMsg = `${res.status} ${res.statusText} - ${errorBody}`;
7473
logMetric('facilitator_proxy_failure', 1, {
7574
method,
7675
status: res.status,
7776
});
78-
throw new Error(`Proxy facilitator failed for ${method}: ${errorMsg}`);
77+
throw new FacilitatorProxyError();
7978
}
8079

8180
const data = await res.json();

0 commit comments

Comments
 (0)