MCPcopy Create free account
hub / github.com/pollinations/pollinations / extractUpstreamMessage

Function extractUpstreamMessage

shared/error.ts:86–99  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

84}
85
86function extractUpstreamMessage(body: string): string {
87 try {
88 const parsed = JSON.parse(body);
89 const extracted =
90 parsed?.details?.error?.message ||
91 parsed?.error?.message ||
92 parsed?.message ||
93 (typeof parsed?.error === "string" ? parsed.error : null);
94 if (typeof extracted === "string" && extracted) return extracted;
95 } catch {
96 // Not JSON — fall through to raw body
97 }
98 return body;
99}
100
101const GenericErrorDetailsSchema = z
102 .object({

Callers 1

ensureUpstreamOkFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected