mirror of https://github.com/buster-so/buster.git
better error handling for get report
This commit is contained in:
parent
63dec3acda
commit
62644bffeb
|
@ -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,7 +15,8 @@ export async function getReportHandler(
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new Hono().get('/', async (c) => {
|
const app = new Hono()
|
||||||
|
.get('/', async (c) => {
|
||||||
const reportId = c.req.param('id');
|
const reportId = c.req.param('id');
|
||||||
const user = c.get('busterUser');
|
const user = c.get('busterUser');
|
||||||
|
|
||||||
|
@ -24,6 +26,7 @@ const app = new Hono().get('/', async (c) => {
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 })}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue