UNPKG

scrivito

Version:

Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.

25 lines (19 loc) 634 B
import { isObject } from 'scrivito_sdk/common'; export type ErrorResponse = { error: string; code?: string; details?: object; }; export function isErrorResponse( parsedResponse: unknown ): parsedResponse is ErrorResponse { if (!isObject(parsedResponse)) return false; const errorType = typeof (parsedResponse as ErrorResponse).error; const codeType = typeof (parsedResponse as ErrorResponse).code; const details = (parsedResponse as ErrorResponse).details; return ( errorType === 'string' && (codeType === 'string' || codeType === 'undefined') && (isObject(details) || details === undefined) ); }