diff --git a/packages/core/client/src/application/components/defaultComponents.tsx b/packages/core/client/src/application/components/defaultComponents.tsx
index aeb2c475b9..31801e97ed 100644
--- a/packages/core/client/src/application/components/defaultComponents.tsx
+++ b/packages/core/client/src/application/components/defaultComponents.tsx
@@ -11,10 +11,11 @@ import React, { FC } from 'react';
import { MainComponent } from './MainComponent';
const Loading: FC = () =>
Loading...
;
-const AppError: FC<{ error: Error }> = ({ error }) => {
+const AppError: FC<{ error: Error & { title?: string } }> = ({ error }) => {
+ const title = error?.title || 'App Error';
return (
-
App Error
+
{title}
{error?.message}
{process.env.__TEST__ && error?.stack}
diff --git a/packages/core/client/src/nocobase-buildin-plugin/index.tsx b/packages/core/client/src/nocobase-buildin-plugin/index.tsx
index cc706c760a..c53173b30a 100644
--- a/packages/core/client/src/nocobase-buildin-plugin/index.tsx
+++ b/packages/core/client/src/nocobase-buildin-plugin/index.tsx
@@ -74,7 +74,7 @@ const useErrorProps = (app: Application, error: any) => {
}
};
-const AppError: FC<{ error: Error; app: Application }> = observer(
+const AppError: FC<{ error: Error & { title?: string }; app: Application }> = observer(
({ app, error }) => {
const props = getProps(app);
return (
@@ -87,7 +87,7 @@ const AppError: FC<{ error: Error; app: Application }> = observer(
transform: translate(0, -50%);
`}
status="error"
- title={app.i18n.t('App error')}
+ title={error?.title || app.i18n.t('App error', { ns: 'client' })}
subTitle={app.i18n.t(error?.message)}
{...props}
extra={[
diff --git a/packages/plugins/@nocobase/plugin-error-handler/src/server/error-handler.ts b/packages/plugins/@nocobase/plugin-error-handler/src/server/error-handler.ts
index 45d27d7a05..0cf3286bbf 100644
--- a/packages/plugins/@nocobase/plugin-error-handler/src/server/error-handler.ts
+++ b/packages/plugins/@nocobase/plugin-error-handler/src/server/error-handler.ts
@@ -26,13 +26,16 @@ export class ErrorHandler {
message += `: ${err.cause.message}`;
}
+ const errorData: { message: string; code: string; title?: string } = {
+ message,
+ code: err.code,
+ };
+
+ if (err?.title) {
+ errorData.title = err.title;
+ }
ctx.body = {
- errors: [
- {
- message,
- code: err.code,
- },
- ],
+ errors: [errorData],
};
}