Skip to content

Commit f08b9b7

Browse files
committed
addressing PR comments
1 parent 9046274 commit f08b9b7

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

packages/server/src/adapter/next/app-route-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { SchemaDef } from '@zenstackhq/orm/schema';
22
import { NextRequest, NextResponse } from 'next/server';
33
import type { AppRouteRequestHandlerOptions } from '.';
4-
import { log } from '../../api/utils';
4+
import { logInternalError } from '../common';
55

66
type Context = { params: Promise<{ path: string[] }> };
77

@@ -59,7 +59,7 @@ export default function factory<Schema extends SchemaDef>(
5959
});
6060
return NextResponse.json(r.body, { status: r.status });
6161
} catch (err) {
62-
log(options.apiHandler.log, 'error', `An unhandled error occurred while processing the request: ${err}${err instanceof Error ? '\n' + err.stack : ''}`);
62+
logInternalError(options.apiHandler.log, err);
6363
return NextResponse.json({ message: 'An internal server error occurred' }, { status: 500 });
6464
}
6565
};

packages/server/src/adapter/next/pages-route-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { SchemaDef } from '@zenstackhq/orm/schema';
22
import type { NextApiRequest, NextApiResponse } from 'next';
33
import type { PageRouteRequestHandlerOptions } from '.';
4-
import { log } from '../../api/utils';
4+
import { logInternalError } from '../common';
55

66
/**
77
* Creates a Next.js API endpoint "pages" router request handler that handles ZenStack CRUD requests.
@@ -35,7 +35,7 @@ export default function factory<Schema extends SchemaDef>(
3535
});
3636
res.status(r.status).send(r.body);
3737
} catch (err) {
38-
log(options.apiHandler.log, 'error', `An unhandled error occurred while processing the request: ${err}${err instanceof Error ? '\n' + err.stack : ''}`);
38+
logInternalError(options.apiHandler.log, err);
3939
res.status(500).send({ message: 'An internal server error occurred' });
4040
}
4141
};

packages/server/src/adapter/nuxt/handler.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { ClientContract } from '@zenstackhq/orm';
22
import type { SchemaDef } from '@zenstackhq/orm/schema';
33
import {
4-
type EventHandlerRequest,
54
H3Event,
65
defineEventHandler,
76
getQuery,
87
getRouterParams,
9-
readBody
8+
readBody,
9+
type EventHandlerRequest
1010
} from 'h3';
11-
import type { CommonAdapterOptions } from '../common';
11+
import { logInternalError, type CommonAdapterOptions } from '../common';
1212

1313
/**
1414
* Nuxt request handler options
@@ -49,7 +49,8 @@ export function createEventHandler<Schema extends SchemaDef>(options: HandlerOpt
4949
return body;
5050
} catch (err) {
5151
event.res.status = 500;
52-
return { message: `An unhandled error occurred: ${err}` };
52+
logInternalError(options.apiHandler.log, err);
53+
return { message: 'An internal server error occurred' };
5354
}
5455
});
5556
}

0 commit comments

Comments
 (0)