🀯Errors

Error codes

You can find all error codes in VidalClientErrorEnum, this enum is exported from library.

export enum VidalClientErrorEnum {
  VIDAL_REQUEST_FAILED = 'VIDAL_REQUEST_FAILED',
  VIDAL_PACKAGE_NOT_FOUND = 'VIDAL_PACKAGE_NOT_FOUND',
  VIDAL_PACKAGES_NOT_FOUND = 'VIDAL_PACKAGES_NOT_FOUND',
  VIDAL_VMP_NOT_FOUND = 'VIDAL_VMP_NOT_FOUND',
  VIDAL_PRODUCTS_NOT_FOUND = 'VIDAL_PRODUCTS_NOT_FOUND',
  VIDAL_MOLECULES_NOT_FOUND = 'VIDAL_MOLECULES_NOT_FOUND',
  VIDAL_INDICATORS_NOT_FOUND = 'VIDAL_INDICATORS_NOT_FOUND',
  NO_GENERIC_FOUND = 'NO_GENERIC_FOUND',
  BAD_INPUT = 'BAD_INPUT',
}

Errors usage

When using this library, you will find two types of errors. VidalClientRequestError and VidalClientError

VidalClientRequestError is used if an error occurs during the request to the vidal API, the code will always be VIDAL_REQUEST_FAILED and you will be able to find the answer of vidal in error.vidalResponse

The second one, VidalClientError, is used for business errors, for example when an object doesn't exist or a verification error. In this error, you can find more details in error.baseError

Here you can find, error formats

This two class are exported from library

class VidalClientError extends Error {
  baseError?: Error;

  code: VidalClientErrorEnum;
}
class VidalClientRequestError extends Error {
  vidalResponse: {
    status: number;
    statusText: string;
    data?: string;
  };

  code: VidalClientErrorEnum;
}

Last updated