UNPKG

skola24-node

Version:

Library that provides convenient access to the Skola24 API.

63 lines 2.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const name = (name) => `Skola24${name}`; var Skola24Errors; (function (Skola24Errors) { class BaseError extends Error { request; url; constructor(message, request, url) { super(message); this.request = request; this.url = url; if (Error.captureStackTrace) { Error.captureStackTrace(this, BaseError); } } } class GetTimetableViewerUnitsValidationErrorsError extends BaseError { validationErrors; constructor(validationErrors, request, url) { const message = "All errors: " + validationErrors.map(v => v.description).join("; "); super(message, request, url); this.name = name("GetTimetableViewerUnitsValidationErrorsError"); this.validationErrors = validationErrors; } } Skola24Errors.GetTimetableViewerUnitsValidationErrorsError = GetTimetableViewerUnitsValidationErrorsError; class ValidationError extends BaseError { validation; constructor(validation, request, url) { const errorPotentialCauses = { 9000: "Did you provide a valid selectionType?", 9002: "Did you provide a valid scheduleDay?", 9003: "Did you provide valid width and height?", 9005: "Did you provide the correct unitGuid?", 9006: "Did you provide correct selection?", 3: "There might be a mismatch between the selection type and selection. Alternatively, the schedule could be anonymous.", 4: "You might be providing the wrong encrypted signature for the selection parameter.", 6: "Did you provide a valid render key?", 100: "Provided Host is not valid." }; const message = "All errors: " + validation.map(v => { const potentialCause = errorPotentialCauses[v.code]; return `\nMessage: ${v.message}, Code: ${v.code}. ${potentialCause ?? ""}`; }).join(""); super(message, request, url); this.name = name("ValidationError"); this.validation = validation; } } Skola24Errors.ValidationError = ValidationError; class ExceptionError extends BaseError { exception; constructor(exception, request, url) { const message = `Code: ${exception.code}`; super(message, request, url); this.name = name("ExceptionError"); } } Skola24Errors.ExceptionError = ExceptionError; })(Skola24Errors || (Skola24Errors = {})); exports.default = Skola24Errors; //# sourceMappingURL=Errors.js.map