Skip to content

Commit a99d4d5

Browse files
committed
chore: cleanup console logs
1 parent 0728a86 commit a99d4d5

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/handlers/handlerUtils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,16 @@ export async function tryTargetsRecursively(
787787
);
788788
}
789789
} catch (error: any) {
790-
console.error('tryTargetsRecursively error: ', error);
791790
// tryPost always returns a Response.
792791
// TypeError will check for all unhandled exceptions.
793792
// GatewayError will check for all handled exceptions which cannot allow the request to proceed.
794793
if (error instanceof TypeError || error instanceof GatewayError) {
794+
console.error(
795+
'tryTargetsRecursively error: ',
796+
error.message,
797+
error.cause,
798+
error.stack
799+
);
795800
const errorMessage =
796801
error instanceof GatewayError
797802
? error.message

src/handlers/retryHandler.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ export const retryRequest = async (
175175
retries: retryCount,
176176
onRetry: (error: Error, attempt: number) => {
177177
lastAttempt = attempt;
178-
console.warn(`Failed in Retry attempt ${attempt}. Error: ${error}`);
179178
},
180179
randomize: false,
181180
}
@@ -186,13 +185,18 @@ export const retryRequest = async (
186185
error.cause instanceof Error &&
187186
error.cause?.name === 'ConnectTimeoutError'
188187
) {
189-
console.error('ConnectTimeoutError: ', error.cause);
188+
console.error(
189+
'retryRequest ConnectTimeoutError error:',
190+
error.cause,
191+
error.message
192+
);
190193
// This error comes in case the host address is unreachable. Empty status code used to get returned
191194
// from here hence no retry logic used to get called.
192195
lastResponse = new Response(error.message, {
193196
status: 503,
194197
});
195198
} else if (!error.status || error instanceof TypeError) {
199+
console.error('retryRequest error:', error.cause, error.message);
196200
// The retry handler will always attach status code to the error object
197201
lastResponse = new Response(
198202
`Message: ${error.message} Cause: ${error.cause ?? 'NA'} Name: ${error.name}`,
@@ -206,9 +210,6 @@ export const retryRequest = async (
206210
headers: error.headers,
207211
});
208212
}
209-
console.warn(
210-
`Tried ${lastAttempt ?? 1} time(s) but failed. Error: ${JSON.stringify(error)}`
211-
);
212213
}
213214
return {
214215
response: lastResponse as Response,

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ app.notFound((c) => c.json({ message: 'Not Found', ok: false }, 404));
109109
* Otherwise, logs the error and returns a JSON response with status code 500.
110110
*/
111111
app.onError((err, c) => {
112-
console.error('Global Error Handler: ', err);
112+
console.error('Global Error Handler: ', err.message, err.cause, err.stack);
113113
if (err instanceof HTTPException) {
114114
return err.getResponse();
115115
}

0 commit comments

Comments
 (0)