chore: merge blocksuite source code (#9213)

This commit is contained in:
Mirone
2024-12-20 15:38:06 +08:00
committed by GitHub
parent 2c9ef916f4
commit 30200ff86d
2031 changed files with 238888 additions and 229 deletions

View File

@@ -0,0 +1,30 @@
export enum ErrorCode {
DefaultRuntimeError = 1,
ReactiveProxyError,
DocCollectionError,
ModelCRUDError,
ValueNotExists,
ValueNotInstanceOf,
ValueNotEqual,
MigrationError,
SchemaValidateError,
TransformerError,
InlineEditorError,
TransformerNotImplementedError,
EdgelessExportError,
CommandError,
EventDispatcherError,
SelectionError,
GfxBlockElementError,
MissingViewModelError,
DatabaseBlockError,
ParsingError,
UserAbortError,
ExecutionError,
// Fatal error should be greater than 10000
DefaultFatalError = 10000,
NoRootModelError,
NoSurfaceModelError,
NoneSupportedSSRError,
}

View File

@@ -0,0 +1,34 @@
import type { ErrorCode } from './code.js';
export class BlockSuiteError extends Error {
code: ErrorCode;
isFatal: boolean;
constructor(code: ErrorCode, message: string, options?: { cause: Error }) {
super(message, options);
this.name = 'BlockSuiteError';
this.code = code;
this.isFatal = code >= 10000;
}
}
export function handleError(error: Error) {
if (!(error instanceof BlockSuiteError)) {
throw error;
}
if (error.isFatal) {
throw new Error(
'A fatal error for BlockSuite occurs, please contact the team if you find this.',
{ cause: error }
);
}
console.error(
"A runtime error for BlockSuite occurs, you can ignore this error if it won't break the user experience."
);
console.error(error.stack);
}
export * from './code.js';