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

37 lines (36 loc) 866 B
"use strict"; import { PrinterError } from "../../core/index.js"; import { PrinterErrorResult, PrinterErrorStatusMapping } from "../constants/index.js"; export function throwProcessedError({ methodName, errorCode, messagesMapping, statusMapping = PrinterErrorStatusMapping }) { const result = !isNaN(Number(errorCode)) ? errorCode : PrinterErrorResult.ERR_FAILURE; const message = messagesMapping[result]; const status = statusMapping[result]; throw new PrinterError({ status: status, message: message, methodName }); } export 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