import { PACKAGE_NAME } from "src/shared/constants" ; type Code = "NotFoundAccount" | "InvalidArgument" | "NoNetworkConnection" ; const statusCodesMap = { NotFoundAccount : `${ PACKAGE_NAME }:NotFoundAccount` , InvalidArgument : `${ PACKAGE_NAME }:InvalidArgument` , NoNetworkConnection : `${ PACKAGE_NAME }:NoNetworkConnection` , } ; export class StatusCodeError extends Error { public static getStatusCodeValue ( statusCode ) { return statusCodesMap [ statusCode ] ; } public static hasStatusCodeValue ( error , statusCode ) { return ( "statusCode" in error ) && error . statusCode === statusCodesMap [ statusCode ] ; } public readonly statusCode : string ; constructor ( message , statusCode ) { super ( message ) ; this . statusCode = StatusCodeError . getStatusCodeValue ( statusCode ) ; Object . setPrototypeOf ( this , new . target . prototype ) ; } }