- 后端:Bun + Hono + Drizzle ORM + SQLite - 前端:Vue 3 + Naive UI + ECharts - 项目管理:创建项目 + 绑定 Git 仓库 - OKR 系统:目标/关键结果 CRUD + 进度追踪 - Git 同步:Gitea API 自动同步 commit/PR + 作者关联 - 数据看板:项目 OKR 进度 + KR 状态分布 + 代码活动 - 权限体系:admin/manager/developer/viewer 四级 - Docker 部署:docker-compose + nginx Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
776 B
TypeScript
36 lines
776 B
TypeScript
import { Context } from 'hono';
|
|
import { HTTPException } from 'hono/http-exception';
|
|
|
|
export class AppError extends Error {
|
|
constructor(
|
|
public code: number,
|
|
message: string,
|
|
public status: number = 400
|
|
) {
|
|
super(message);
|
|
this.name = 'AppError';
|
|
}
|
|
}
|
|
|
|
export function errorHandler(err: Error, c: Context) {
|
|
if (err instanceof AppError) {
|
|
return c.json(
|
|
{ code: err.code, data: null, message: err.message },
|
|
err.status as any
|
|
);
|
|
}
|
|
|
|
if (err instanceof HTTPException) {
|
|
return c.json(
|
|
{ code: err.status * 100, data: null, message: err.message },
|
|
err.status
|
|
);
|
|
}
|
|
|
|
console.error('Unhandled error:', err);
|
|
return c.json(
|
|
{ code: 50001, data: null, message: 'Internal server error' },
|
|
500
|
|
);
|
|
}
|