Function isConfigError

  • Checks if the given error is an instance of ConfigError with the specified error type.

    Type Parameters

    • ErrorName extends
          | "optionValidationError"
          | "configValidationError"
          | "httpResponseError"
          | "httpGeneralError"
          | "schemaNotFoundError"
          | "schemasPackageVersionMismatchError"
          | "schemaVersionMismatchError"
          | "promClientNotInstalledError"

    Parameters

    • error: unknown

      The error to check.

    • errorName: ErrorName

      The name of the error to check against.

    Returns error is ConfigError<
        ErrorName,
        {
            configValidationError: { code: 2; payload: ValidationError[] };
            httpGeneralError: { code: 4; payload: Error };
            httpResponseError: {
                code: 3;
                payload: Pick<ResponseData, "headers" | "statusCode"> & { body: string };
            };
            optionValidationError: { code: 1; payload: ValidationError[] };
            promClientNotInstalledError: { code: 8; payload: { message: string } };
            schemaNotFoundError: { code: 5; payload: { schemaPath: string } };
            schemasPackageVersionMismatchError: {
                code: 6;
                payload: { localPackageVersion: string; remotePackageVersion: string };
            };
            schemaVersionMismatchError: {
                code: 7;
                payload: { localSchemaVersion: string; remoteSchemaVersion: string };
            };
        }[ErrorName]["payload"],
    >

    true if the error is an instance of ConfigError with the specified error name, false otherwise.