MCPcopy Create free account
hub / github.com/denoland/std / parseProblemDetails

Function parseProblemDetails

http/unstable_problem_details.ts:327–339  ·  view source on GitHub ↗
(input: unknown)

Source from the content-addressed store, hash-verified

325 * ```
326 */
327export function parseProblemDetails<
328 T extends ProblemDetailsExtensions = Record<string, never>,
329>(input: unknown): ProblemDetails<T> {
330 // A `Response` is a non-null, non-array object with no enumerable own keys,
331 // so it would silently parse to an empty result. Reject it explicitly so
332 // callers who forgot to migrate to `parseProblemDetailsResponse` fail loudly.
333 if (input instanceof Response) {
334 throw new TypeError(
335 "Cannot parse Problem Details: input is a Response, use parseProblemDetailsResponse instead",
336 );
337 }
338 return normalizeParsedProblemDetails(input) as ProblemDetails<T>;
339}
340
341/**
342 * Parses a `Response` body into a {@linkcode ProblemDetails}.

Calls 1

Tested by

no test coverage detected