Files
twenty/packages/twenty-sdk/src/cli/utilities/run-safe.ts
T
martmull 731e297147 Twenty sdk cli oauth (#18638)
<img width="1418" height="804" alt="image"
src="https://github.com/user-attachments/assets/de6c8222-6496-4a71-bc21-7e5e1269d5cb"
/>

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Félix Malfait <felix@twenty.com>
2026-03-17 11:43:17 +01:00

19 lines
436 B
TypeScript

import { type CommandResult } from '@/cli/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',
},
};
}
};