All three functions exposed by the plugin —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/luis3132/tauri-plugin-thermal-printer/llms.txt
Use this file to discover all available pages before exploring further.
print_thermal_printer, test_thermal_printer, and list_thermal_printers — are async and return a Promise that rejects with a plain string when something goes wrong. There are no error classes or structured error objects: the rejection value is a human-readable message you can display directly to the user or log for debugging.
Always wrap every call in a try/catch block. Letting a thermal printer error propagate unhandled will cause an unhandled promise rejection in your application.
Function Return Types
| Function | Return type | Throws |
|---|---|---|
print_thermal_printer(job) | Promise<void> | string describing the failure |
test_thermal_printer(request) | Promise<void> | string describing the failure |
list_thermal_printers() | Promise<PrinterInfo[]> | string describing the failure |
Error Messages Reference
The following error strings are emitted directly by the plugin’s Rust layer and will appear verbatim as the caught value in yourcatch block.
Printer not specified
The
printer field in PrintJobRequest is an empty string. Always supply a non-empty printer name (desktop) or MAC address (Android).Barcode data cannot be empty
A
Barcode section was added with an empty data string. Validate barcode data before building the job.Barcode type 'EAN13' only accepts numeric digits
Numeric-only barcode types (
UPC-A, UPC-E, EAN13, EAN8, ITF) reject non-digit characters. Strip any spaces, dashes, or letters before passing the data.QR data length exceeds maximum
The full message is
"QR data length 5000 exceeds maximum 4296 for error correction level 'M'". The maximum QR payload depends on the error_correction level — use "L" for the largest capacity (7089 chars).Table row has wrong cell count
The full message is
"Table row 2 has 2 cells but 3 columns declared". Every row in body (and every entry in header) must have exactly columns cells.column_widths sum mismatch
The full message is
"column_widths sum (45) must equal paper chars_per_line (48)". When you provide column_widths, their sum must equal the paper’s characters-per-line (e.g. 48 for Mm80).Image data cannot be empty
An
Image section was added with an empty data string. Ensure your base64 image string is non-empty before building the job.No sections to print
The
sections array in PrintJobRequest is empty. Add at least one printable section.Handling Each Function
print_thermal_printer
test_thermal_printer
list_thermal_printers
list_thermal_printers can fail if the system’s printer subsystem is unavailable — for example if CUPS is not running on Linux, or if Bluetooth permissions are denied on Android.
Combining List and Print with Error Handling
A common pattern is to list printers, let the user choose one, and then send a print job — all with full error handling at every step:Best Practices
Always use try/catch
Every plugin call can throw. Wrapping in
try/catch prevents unhandled promise rejections and gives you a chance to show the user a meaningful message.Validate before sending
Check that barcode data is non-empty and numeric for types that require it, that QR data does not exceed the limit for your chosen error correction level, and that table
column_widths sum matches the paper’s chars_per_line.Show errors to users
The thrown string is already human-readable. Surface it directly in a toast, alert, or status bar so the operator can act on it (e.g. “Printer not specified” → prompt them to select a printer).
Log for debugging
Log the full error string alongside the job parameters for diagnosing encoding or configuration issues in production. The error message includes the relevant values (e.g. the actual QR data length and the maximum).