Skip to content

IPC, errors and logging

Always use the @/core/ipc wrapper on the frontend; never call invoke directly:

import { ipc } from '@/core/ipc';
const rows = await ipc<Row[]>('db_query_values', { sql, params });

Command names are generated into src/core/ipc/commands.gen.ts by scripts/gen-commands.mjs: it reads src-tauri/framework-commands.json and scans plugin #[tauri::command] functions to produce a union type of framework + plugin commands. Calling an unregistered command fails type-checking.

Every Rust command returns AppError{code, message}, whose code aligns with the frontend ErrorCode in @/core/errors. Errors flow through one pipeline: normalize → log → toast when uncaught.

Err(crate::error::AppError::custom("TIME_ERROR", "clock went backwards"))

Use the logger from @/core/logger, or ctx.logger in a plugin’s setup.ts; on the Rust side use log. Never use bare println!.

Both runtimes write to the app log directory (on macOS ~/Library/Logs/<identifier>/); console is intercepted and the level is adjustable at runtime from settings.