How to use node-errors-helpers - 10 common examples

To help you get started, we’ve selected a few node-errors-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Travelport-Ukraine / uapi-json / src / Services / Hotels / HotelsErrors.js View on Github external
import {
  createErrorClass,
  createErrorsList,
} from 'node-errors-helpers';
import errorTypes from '../../error-types';

// Validation errors
export const HotelsValidationError = createErrorClass(
  'HotelsValidationError',
  'Hotels service validation error',
  errorTypes.ValidationError
);
export const TravellersError = createErrorClass(
  'TravellersError',
  'Travellers information is incorrect',
  HotelsValidationError
);
export const ContactError = createErrorClass(
  'AddressError',
  'Address information is incorrect',
  HotelsValidationError
);
export const PaymentDataError = createErrorClass(
  'PaymentDataError',
github Travelport-Ukraine / uapi-json / src / Services / Hotels / HotelsErrors.js View on Github external
StreetMissing: 'Missing Street in request',
  PostalCodeMissing: 'Missing PostalCode in request',
}, ContactError));
Object.assign(PaymentDataError, createErrorsList({
  GuaranteeMissing: 'Missing Guarantee',
  CvvMissing: 'Missing CVV',
  CvvInvalid: 'Invalid CVV',
  ExpDateMissing: 'Missing ExpDate',
  CardNumberMissing: 'Missing CardNumber',
  CardTypeMissing: 'Missing CardType',
  CardTypeInvalid: 'Invalid CardType',
  CardHolderMissing: 'Missing CardHolder',
}, PaymentDataError));

// Parsing errors
const HotelsParsingError = createErrorClass(
  'HotelsParsingError',
  'Hotels service parsing error',
  errorTypes.ParsingError
);
Object.assign(HotelsParsingError, createErrorsList({
  SearchParsingError: 'Cant parse XML response. #HotelsParser.searchParse()',
  MediaParsingError: 'Cant parse XML response. #HotelsParser.mediaParse()',
  RateParsingError: 'Cant parse XML response. #HotelsParser.rateParse()',
  BookingParsingError: 'Cant parse XML response. #HotelsParser.bookParse()',
  CancelBookingParsingError: 'Cant parse XML response. #HotelsParser.cancelBookParse()',
}, HotelsParsingError));

// Runtime errors
const HotelsRuntimeError = createErrorClass(
  'HotelsRuntimeError',
  'Hotels service runtime error',
github Travelport-Ukraine / uapi-json / src / Services / Hotels / HotelsErrors.js View on Github external
import {
  createErrorClass,
  createErrorsList,
} from 'node-errors-helpers';
import errorTypes from '../../error-types';

// Validation errors
export const HotelsValidationError = createErrorClass(
  'HotelsValidationError',
  'Hotels service validation error',
  errorTypes.ValidationError
);
export const TravellersError = createErrorClass(
  'TravellersError',
  'Travellers information is incorrect',
  HotelsValidationError
);
export const ContactError = createErrorClass(
  'AddressError',
  'Address information is incorrect',
  HotelsValidationError
);
export const PaymentDataError = createErrorClass(
  'PaymentDataError',
  'Payment information is incorrect',
  HotelsValidationError
);
Object.assign(HotelsValidationError, {
  TravellersError,
github Travelport-Ukraine / uapi-json / src / Services / Terminal / TerminalErrors.js View on Github external
const {
  createErrorClass,
  createErrorsList,
} = require('node-errors-helpers');
const errorTypes = require('../../error-types');

// Validation errors
const TerminalValidationError = createErrorClass(
  'TerminalValidationError',
  'Terminal service validation error',
  errorTypes.ValidationError
);
Object.assign(TerminalValidationError, createErrorsList({
  ParamsMissing: 'Params are missing',
  ParamsInvalidType: 'Params should be passed as object',
  CommandMissing: 'Command is missing',
  CommandInvalid: 'Command is invalid',
  SessionTokenMissing: 'Session token is missing',
  SessionTokenInvalid: 'Session token is invalid',
  SessionTimeoutInvalid: 'Session timeout value is invalid',
  SessionTimeoutTooLow: 'Timeout value must be positive integer',
}, TerminalValidationError));

// Parsing errors
github Travelport-Ukraine / uapi-json / src / Services / Utils / UtilsErrors.js View on Github external
'Utils service validation error',
  errorTypes.ValidationError
);
Object.assign(UtilsValidationError, createErrorsList({
  CurrenciesMissing: 'Missing currencies',
}, UtilsValidationError));

// Parsing errors
const UtilsParsingError = createErrorClass(
  'UtilsParsingError',
  'Utils service parsing error',
  errorTypes.ParsingError
);

// Runtime errors
const UtilsRuntimeError = createErrorClass(
  'UtilsRuntimeError',
  'Utils service runtime error',
  errorTypes.RuntimeError
);

module.exports = {
  UtilsValidationError,
  UtilsParsingError,
  UtilsRuntimeError,
};
github Travelport-Ukraine / uapi-json / src / Request / RequestErrors.js View on Github external
// Runtime errors
const RequestRuntimeError = createErrorClass(
  'RequestRuntimeError',
  'Request runtime error',
  errorTypes.RuntimeError
);
Object.assign(RequestRuntimeError, createErrorsList({
  TemplateFileMissing: 'XML template not found for request',
  VersionParsingError: 'Error during parsing version of uapi',
  UnhandledError: 'Error during request. Please try again later',
  ResultsMissing: 'Missing results in response',
}, RequestRuntimeError));

// Soap errors
const RequestSoapError = createErrorClass(
  'RequestSoapError',
  'Request SOAP error',
  errorTypes.SoapError
);
Object.assign(RequestSoapError, createErrorsList({
  SoapUnexpectedError: 'Unexpected error during soap request',
  SoapRequestError: 'Error during request to SOAP API. Check url validity',
  SoapParsingError: 'SOAP response parsing failed',
  SoapServerError: 'SOAP server error. Check auth and other data',
}, RequestSoapError));

module.exports = {
  RequestValidationError,
  RequestRuntimeError,
  RequestSoapError,
};
github Travelport-Ukraine / uapi-json / src / Request / RequestErrors.js View on Github external
// Validation errors
const RequestValidationError = createErrorClass(
  'RequestValidationError',
  'Request validation error',
  errorTypes.ValidationError
);
Object.assign(RequestValidationError, createErrorsList({
  ServiceUrlMissing: 'Service URL is missing',
  AuthDataMissing: 'Auth data is missing',
  ParamsMissing: 'Params for function are missing',
  RequestTypeUndefined: 'Undefined request type',
}, RequestValidationError));

// Runtime errors
const RequestRuntimeError = createErrorClass(
  'RequestRuntimeError',
  'Request runtime error',
  errorTypes.RuntimeError
);
Object.assign(RequestRuntimeError, createErrorsList({
  TemplateFileMissing: 'XML template not found for request',
  VersionParsingError: 'Error during parsing version of uapi',
  UnhandledError: 'Error during request. Please try again later',
  ResultsMissing: 'Missing results in response',
}, RequestRuntimeError));

// Soap errors
const RequestSoapError = createErrorClass(
  'RequestSoapError',
  'Request SOAP error',
  errorTypes.SoapError
github Travelport-Ukraine / uapi-json / src / Services / Utils / UtilsErrors.js View on Github external
createErrorsList,
} = require('node-errors-helpers');
const errorTypes = require('../../error-types');

// Validation errors
const UtilsValidationError = createErrorClass(
  'UtilsValidationError',
  'Utils service validation error',
  errorTypes.ValidationError
);
Object.assign(UtilsValidationError, createErrorsList({
  CurrenciesMissing: 'Missing currencies',
}, UtilsValidationError));

// Parsing errors
const UtilsParsingError = createErrorClass(
  'UtilsParsingError',
  'Utils service parsing error',
  errorTypes.ParsingError
);

// Runtime errors
const UtilsRuntimeError = createErrorClass(
  'UtilsRuntimeError',
  'Utils service runtime error',
  errorTypes.RuntimeError
);

module.exports = {
  UtilsValidationError,
  UtilsParsingError,
  UtilsRuntimeError,
github Travelport-Ukraine / uapi-json / src / Services / Air / AirErrors.js View on Github external
PccMissing: 'Pcc is missing in request',
}, GdsValidationError));

const AirFlightInfoValidationError = createErrorClass(
  'AirFlightInfoValidationError',
  ['Air FlightInfo service validation error', 200],
  errorTypes.ValidationError
);
Object.assign(AirFlightInfoValidationError, createErrorsList({
  AirlineMissing: 'Airline is missing in request',
  FlightNumberMissing: 'Flight number is missing in request',
  DepartureMissing: 'Departure is missing in request',
}, AirFlightInfoValidationError));

// Parsing errors
const AirParsingError = createErrorClass(
  'AirParsingError',
  'Air service parsing error',
  errorTypes.ParsingError
);
Object.assign(AirParsingError, createErrorsList({
  ResponseDataMissing: 'One of main data arrays is missing in parsed XML response',
  ReservationsMissing: 'Reservations missing in response',
  BookingInfoError: 'air:BookingInfo should be an array',
  PlatingCarriersError: 'Plating carriers do not coincide across all passenger reservations',
  PTCIsNotSet: 'Code not set for PassengerTypeCode item',
  PlatingCarrierNotSet: 'PlatingCarrier is not set for AirPricingInfo item',
  PTCTypeInvalid: 'PassengerTypeCode is supposed to be a string or array of PassengerTypeCode items',
  HistogramTypeInvalid: 'PassengerType is supposed to be an array',
  MultiplePricingSolutionsNotAllowed: 'Expected only one pricing solution, need to clarify search?',
  PricingSolutionNotFound: 'Pricing solution not found',
  ReservationProviderInfoMissing: 'Can\'t find provider information about reservation',
github Travelport-Ukraine / uapi-json / src / Services / Hotels / HotelsErrors.js View on Github external
);
Object.assign(HotelsParsingError, createErrorsList({
  SearchParsingError: 'Cant parse XML response. #HotelsParser.searchParse()',
  MediaParsingError: 'Cant parse XML response. #HotelsParser.mediaParse()',
  RateParsingError: 'Cant parse XML response. #HotelsParser.rateParse()',
  BookingParsingError: 'Cant parse XML response. #HotelsParser.bookParse()',
  CancelBookingParsingError: 'Cant parse XML response. #HotelsParser.cancelBookParse()',
}, HotelsParsingError));

// Runtime errors
const HotelsRuntimeError = createErrorClass(
  'HotelsRuntimeError',
  'Hotels service runtime error',
  errorTypes.RuntimeError
);
Object.assign(HotelsRuntimeError, createErrorsList({
  NoEnginesResults: 'None of the enabled engines could fulfill your request',
  NoResultsFound: 'No results found',
}, HotelsRuntimeError));

export default {
  HotelsValidationError,
  HotelsParsingError,
  HotelsRuntimeError,
};

node-errors-helpers

Some helpers for better error handling in Node.js

MIT
Latest version published 3 years ago

Package Health Score

46 / 100
Full package analysis