fix(query): preserve original backend errors with fallback detail

This commit is contained in:
zipg authored and GitHub committed 2026-09-03 13:43:55 +08:00
1 parent 76c51b5fa6
commit 8cfd69c7c9
7 files changed
+134 -13

No files matched your search

+3 -1
View File
@@ -141,13 +141,15 @@ function normalizeBackendErrorAtDepth(error: unknown, seen: WeakSet<object>, dep
return null;
}
export const GENERIC_TRANSPORT_FAILURE_MESSAGE = "Backend request failed";
export class BackendErrorException extends Error {
readonly backendError: BackendError;
constructor(error: unknown) {
const backendError = normalizeRawBackendError(error);
const fallbackDetail = boundedFallbackText(error);
const fallbackMessage = sanitizeBackendErrorMessage(fallbackDetail ?? "Backend request failed");
const fallbackMessage = sanitizeBackendErrorMessage(fallbackDetail ?? GENERIC_TRANSPORT_FAILURE_MESSAGE);
super(backendError?.detail ? sanitizeBackendErrorMessage(backendError.detail) : fallbackMessage);
this.name = "BackendErrorException";
this.backendError = backendError ?? {