Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

chore: custom error catch (#3627)

ybzky24a876855a07
diff --git a/packages/core/src/services/command/command.service.ts b/packages/core/src/services/command/command.service.ts
index 0c51ed31a8..c7c2046221 100644
--- a/packages/core/src/services/command/command.service.ts
+++ b/packages/core/src/services/command/command.service.ts
@@ -15,15 +15,15 @@
*/
import type { IAccessor, IDisposable } from '../../common/di';
-import { createIdentifier, Inject, Injector } from '../../common/di';
+import type { IKeyValue } from '../../shared/types';
import { findLast, remove } from '../../common/array';
+import { createIdentifier, Inject, Injector } from '../../common/di';
+import { CustomCommandExecutionError } from '../../common/error';
import { sequence, sequenceAsync } from '../../common/sequence';
import { Disposable, DisposableCollection, toDisposable } from '../../shared/lifecycle';
-import type { IKeyValue } from '../../shared/types';
import { IContextService } from '../context/context.service';
import { ILogService } from '../log/log.service';
-import { CustomCommandExecutionError } from '../../common/error';
/**
* The type of a command.
@@ -270,7 +270,7 @@ class CommandRegistry {
}
}
-interface ICommandExecutionStackItem extends ICommandInfo {}
+interface ICommandExecutionStackItem extends ICommandInfo { }
export const NilCommand: ICommand = {
id: 'nil',
@@ -423,8 +423,12 @@ export class CommandService extends Disposable implements ICommandService {
throw new Error(`[CommandService]: command "${id}" is not registered.`);
} catch (error) {
- this._logService.error(error);
- throw error;
+ if (error instanceof CustomCommandExecutionError) {
+ return false as R;
+ } else {
+ this._logService.error(error);
+ throw error;
+ }
}
}