[SDK] Make public-operations non throw (#18343)

Followup https://github.com/twentyhq/twenty/pull/18320
This commit is contained in:
Paul Rastoin
2026-03-03 14:04:13 +01:00
committed by GitHub
parent 2f09fb8c04
commit 005223de8c
12 changed files with 258 additions and 227 deletions
@@ -0,0 +1,18 @@
import { type CommandResult } from '@/cli/public-operations/types';
export const runSafe = async <T>(
operation: () => Promise<CommandResult<T>>,
fallbackErrorCode: string,
): Promise<CommandResult<T>> => {
try {
return await operation();
} catch (error) {
return {
success: false,
error: {
code: fallbackErrorCode,
message: error instanceof Error ? error.message : 'Unexpected error',
},
};
}
};