(input: unknown)
| 325 | * ``` |
| 326 | */ |
| 327 | export 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}. |
no test coverage detected