UNPKG

react-native-esc-pos-printer

Version:

An unofficial React Native library for printing on an EPSON TM printer with the Epson ePOS SDK for iOS and Epson ePOS SDK for Android

42 lines (41 loc) 998 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.processComplextError = processComplextError; exports.throwProcessedError = throwProcessedError; var _index = require("../../core/index.js"); var _index2 = require("../constants/index.js"); function throwProcessedError({ methodName, errorCode, messagesMapping, statusMapping = _index2.PrinterErrorStatusMapping }) { const result = !isNaN(Number(errorCode)) ? errorCode : _index2.PrinterErrorResult.ERR_FAILURE; const message = messagesMapping[result]; const status = statusMapping[result]; throw new _index.PrinterError({ status: status, message: message, methodName }); } function processComplextError(message) { try { const { type, data } = JSON.parse(message); return { errorType: type, data: String(data) }; } catch (error) { return { errorType: 'result', data: message }; } } //# sourceMappingURL=errors.js.map