From e1ac990de9071db1feb8964f47c4ac1200aa427a Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 8 Feb 2024 13:01:32 +0100 Subject: [PATCH] invokeFunction argument typecheck --- plugos/system.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugos/system.ts b/plugos/system.ts index d4ff4bc9..78138f7d 100644 --- a/plugos/system.ts +++ b/plugos/system.ts @@ -81,6 +81,17 @@ export class System extends EventEmitter> { * @param args an array of arguments to pass to the function */ invokeFunction(name: string, args: any[]): Promise { + // Some sanity type checks + if (typeof name !== "string") { + throw new Error( + `invokeFunction: function name should be a string, got ${typeof name}`, + ); + } + if (!Array.isArray(args)) { + throw new Error( + `invokeFunction: args should be an array, got ${typeof args}`, + ); + } const [plugName, functionName] = name.split("."); if (!functionName) { // Sanity check