better error handling for get report

This commit is contained in:
Nate Kelley 2025-08-04 19:27:18 -06:00
parent 63dec3acda
commit 62644bffeb
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
4 changed files with 26 additions and 18 deletions

View File

@ -2,6 +2,7 @@ import { getReport } from '@buster/database';
import type { GetReportIndividualResponse } from '@buster/server-shared/reports'; import type { GetReportIndividualResponse } from '@buster/server-shared/reports';
import { Hono } from 'hono'; import { Hono } from 'hono';
import { HTTPException } from 'hono/http-exception'; import { HTTPException } from 'hono/http-exception';
import { standardErrorHandler } from '../../../../utils/response';
export async function getReportHandler( export async function getReportHandler(
reportId: string, reportId: string,
@ -14,16 +15,18 @@ export async function getReportHandler(
return response; return response;
} }
const app = new Hono().get('/', async (c) => { const app = new Hono()
const reportId = c.req.param('id'); .get('/', async (c) => {
const user = c.get('busterUser'); const reportId = c.req.param('id');
const user = c.get('busterUser');
if (!reportId) { if (!reportId) {
throw new HTTPException(404, { message: 'Report ID is required' }); throw new HTTPException(404, { message: 'Report ID is required' });
} }
const response: GetReportIndividualResponse = await getReportHandler(reportId, user); const response: GetReportIndividualResponse = await getReportHandler(reportId, user);
return c.json(response); return c.json(response);
}); })
.onError(standardErrorHandler);
export default app; export default app;

View File

@ -1,8 +1,13 @@
import { Hono } from 'hono'; import { Hono } from 'hono';
import { requireAuth } from '../../../middleware/auth'; import { requireAuth } from '../../../middleware/auth';
import { standardErrorHandler } from '../../../utils/response';
import GET from './GET'; import GET from './GET';
import individualReport from './[id]'; import individualReport from './[id]';
const app = new Hono().use('*', requireAuth).route('/', GET).route('/:id', individualReport); const app = new Hono()
.use('*', requireAuth)
.route('/', GET)
.route('/:id', individualReport)
.onError(standardErrorHandler);
export default app; export default app;

View File

@ -69,13 +69,6 @@ const yourStuff = (
label: 'Your stuff', label: 'Your stuff',
id: 'your-stuff', id: 'your-stuff',
items: [ items: [
{
label: 'Reports',
icon: <ASSET_ICONS.reports />,
route: createBusterRoute({ route: BusterRoutes.APP_REPORTS }),
id: BusterRoutes.APP_REPORTS,
active: isActiveCheck('report', BusterRoutes.APP_REPORTS)
},
{ {
label: 'Metrics', label: 'Metrics',
icon: <ASSET_ICONS.metrics />, icon: <ASSET_ICONS.metrics />,
@ -96,6 +89,13 @@ const yourStuff = (
route: createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS }), route: createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS }),
id: BusterRoutes.APP_COLLECTIONS, id: BusterRoutes.APP_COLLECTIONS,
active: isActiveCheck('collection', BusterRoutes.APP_COLLECTIONS) active: isActiveCheck('collection', BusterRoutes.APP_COLLECTIONS)
},
{
label: 'Reports',
icon: <ASSET_ICONS.reports />,
route: createBusterRoute({ route: BusterRoutes.APP_REPORTS }),
id: BusterRoutes.APP_REPORTS,
active: isActiveCheck('report', BusterRoutes.APP_REPORTS)
} }
] ]
}; };

View File

@ -136,7 +136,7 @@ const EmptyState: React.FC<{
return ( return (
<ListEmptyStateWithButton <ListEmptyStateWithButton
title={"You don't have any reports yet."} title={"You don't have any reports yet."}
description={'As soon as you create a report, it will start to appear here.'} description={'As soon as you create a report (via a chat), it will start to appear here.'}
buttonText="New chat" buttonText="New chat"
linkButton={createBusterRoute({ route: BusterRoutes.APP_HOME })} linkButton={createBusterRoute({ route: BusterRoutes.APP_HOME })}
/> />