UNPKG

@dgac/nmb2b-client

Version:

EUROCONTROL Network Manager B2B SOAP client

1 lines 3.23 kB
{"version":3,"file":"NMB2BError.mjs","names":[],"sources":["../../src/utils/NMB2BError.ts"],"sourcesContent":["import type { B2B_Error, Reply, ReplyStatus } from '../Common/types.js';\n\n/**\n * Represents an error response received from NM B2B\n */\nexport class NMB2BError extends Error {\n /**\n * UTC time at which the request was received at NM.\n *\n * Always set when an XML reply is returned, regardless of the possible exceptions that occurred within the request processing.\n */\n declare requestReceptionTime?: Date;\n\n /**\n * Identification of the request. This id is not unique across time: the request is uniquely identified via two attributes: `requestReceptionTime` and `requestId`.\n *\n * Always set when an XML reply is returned, regardless of the possible exceptions that occurred within the request processing.\n */\n declare requestId?: string;\n\n /**\n * UTC time at which NM has sent the reply.\n *\n * Always set when an XML reply is returned, regardless of the possible exceptions that occurred within the request processing.\n */\n declare sendTime?: Date;\n\n /**\n * Status code explaining the error.\n */\n declare status: Exclude<ReplyStatus, 'OK'>;\n\n /**\n * Contains the input validation errors, if any.\n * Set to null if the request successfully passed input validations (i.e. status is not set to `INVALID_INPUT`).\n */\n declare inputValidationErrors?: Array<B2B_Error>;\n\n /**\n * Contains the output validation errors, if any.\n * Set to null if the request successfully passed output validations (i.e. status is not set to `INVALID_OUTPUT`).\n */\n declare outputValidationErrors?: Array<B2B_Error>;\n\n /**\n * Warnings, if any\n */\n declare warnings?: Array<B2B_Error>;\n\n /**\n * Describes an error caused by a SLA violation.\n *\n */\n declare slaError?: B2B_Error;\n\n declare reason?: string;\n\n constructor({\n reply,\n }: {\n reply: Reply & { status: Exclude<ReplyStatus, 'OK'> };\n }) {\n super();\n\n if (reply.requestId) {\n this.requestId = reply.requestId;\n }\n\n if (reply.requestReceptionTime) {\n this.requestReceptionTime = reply.requestReceptionTime;\n }\n\n if (reply.sendTime) {\n this.sendTime = reply.sendTime;\n }\n\n if (reply.inputValidationErrors) {\n this.inputValidationErrors = reply.inputValidationErrors;\n }\n\n if (reply.warnings) {\n this.warnings = reply.warnings;\n }\n\n if (reply.slaError) {\n this.slaError = reply.slaError;\n }\n\n if (reply.reason) {\n this.reason = reply.reason;\n }\n this.status = reply.status;\n this.message = this.status;\n\n if (this.reason) {\n this.message = `${this.message}: ${this.reason}`;\n }\n }\n}\n"],"mappings":";;;;AAKA,IAAa,aAAb,cAAgC,MAAM;CAoDpC,YAAY,EACV,SAGC;AACD,SAAO;AAEP,MAAI,MAAM,UACR,MAAK,YAAY,MAAM;AAGzB,MAAI,MAAM,qBACR,MAAK,uBAAuB,MAAM;AAGpC,MAAI,MAAM,SACR,MAAK,WAAW,MAAM;AAGxB,MAAI,MAAM,sBACR,MAAK,wBAAwB,MAAM;AAGrC,MAAI,MAAM,SACR,MAAK,WAAW,MAAM;AAGxB,MAAI,MAAM,SACR,MAAK,WAAW,MAAM;AAGxB,MAAI,MAAM,OACR,MAAK,SAAS,MAAM;AAEtB,OAAK,SAAS,MAAM;AACpB,OAAK,UAAU,KAAK;AAEpB,MAAI,KAAK,OACP,MAAK,UAAU,GAAG,KAAK,QAAQ,IAAI,KAAK"}