From 332a9e5eabeb853db66315700c283a79f2a01bcc Mon Sep 17 00:00:00 2001 From: Egor Aristov Date: Thu, 23 Oct 2025 16:44:50 +0300 Subject: [PATCH] imaginary example --- example/ts/index.ts | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/example/ts/index.ts b/example/ts/index.ts index 7e30706..a066590 100644 --- a/example/ts/index.ts +++ b/example/ts/index.ts @@ -1,15 +1,36 @@ +import {KittenIPC} from '../../lib/ts/lib.js'; +import GoIpcApi from './goapi.gen.ts'; + /** * @kittenipc api */ class TsIpcApi { Div(a: number, b: number): number { + if (b === 0) { + throw new Error('division by zero'); + } return a / b; } } +async function main() { + const localApi = new TsIpcApi(); + const ipc = new KittenIPC(localApi); + const goApi = new GoIpcApi(ipc); -function main() { + await ipc.start(); + console.log(`12/3=${await goApi.Div(12, 3)}`); + + try { + await goApi.Div(10, 0); + } catch (e) { + console.trace(e); + } + + await ipc.wait(); } -main() +main().catch(e => { + console.trace(e); +});