Error handler callback function.
Handles both ThorVG WASM errors (ThorVGError) and JavaScript errors (Error). Use instanceof to distinguish between error types.
import { init } from '@thorvg/webcanvas';const TVG = await init({ onError: (error, context) => { if (error instanceof ThorVGError) { // WASM error - has error.code console.log('WASM error code:', error.code); } else { // JavaScript error console.log('JS error:', error.message); } }}); Copy
import { init } from '@thorvg/webcanvas';const TVG = await init({ onError: (error, context) => { if (error instanceof ThorVGError) { // WASM error - has error.code console.log('WASM error code:', error.code); } else { // JavaScript error console.log('JS error:', error.message); } }});
Error handler callback function.
Handles both ThorVG WASM errors (ThorVGError) and JavaScript errors (Error). Use instanceof to distinguish between error types.
Example