refactor(editor-app): 改进架构和类型安全 (#226)
* refactor(editor-app): 改进架构和类型安全 * refactor(editor-app): 开始拆分 Inspector.tsx - 创建基础架构 * refactor(editor-app): 完成 Inspector.tsx 拆分 * refactor(editor-app): 优化 Inspector 类型定义,消除所有 any 使用 * refactor(editor): 实现可扩展的属性渲染器系统 * Potential fix for code scanning alert no. 231: Unused variable, import, function or class Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix(ci): 防止 Codecov 服务故障阻塞 CI 流程 --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
57
packages/editor-app/src/domain/errors/PluginError.ts
Normal file
57
packages/editor-app/src/domain/errors/PluginError.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { DomainError } from './DomainError';
|
||||
|
||||
export class PluginError extends DomainError {
|
||||
constructor(
|
||||
message: string,
|
||||
public readonly pluginId?: string,
|
||||
public readonly pluginName?: string,
|
||||
public readonly operation?: 'load' | 'activate' | 'deactivate' | 'execute',
|
||||
public readonly originalError?: Error
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
getUserMessage(): string {
|
||||
const operationMap = {
|
||||
load: '加载',
|
||||
activate: '激活',
|
||||
deactivate: '停用',
|
||||
execute: '执行'
|
||||
};
|
||||
|
||||
const operationText = this.operation ? operationMap[this.operation] : '操作';
|
||||
const pluginText = this.pluginName || this.pluginId || '插件';
|
||||
|
||||
return `${pluginText}${operationText}失败: ${this.message}`;
|
||||
}
|
||||
|
||||
static loadFailed(pluginId: string, error?: Error): PluginError {
|
||||
return new PluginError(
|
||||
error?.message || '插件加载失败',
|
||||
pluginId,
|
||||
undefined,
|
||||
'load',
|
||||
error
|
||||
);
|
||||
}
|
||||
|
||||
static activateFailed(pluginId: string, pluginName: string, error?: Error): PluginError {
|
||||
return new PluginError(
|
||||
error?.message || '插件激活失败',
|
||||
pluginId,
|
||||
pluginName,
|
||||
'activate',
|
||||
error
|
||||
);
|
||||
}
|
||||
|
||||
static executeFailed(pluginId: string, error?: Error): PluginError {
|
||||
return new PluginError(
|
||||
error?.message || '插件执行失败',
|
||||
pluginId,
|
||||
undefined,
|
||||
'execute',
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user