mirror of
https://github.com/logto-io/logto.git
synced 2025-04-07 23:01:25 -05:00
refactor(core): log cloudflare error (#5399)
This commit is contained in:
parent
39b963daf3
commit
40eeea8cc0
2 changed files with 3 additions and 1 deletions
packages/core/src
|
@ -129,7 +129,7 @@ export default function applicationRoutes<T extends AuthedRouter>(
|
|||
koaGuard({
|
||||
body: applicationCreateGuard,
|
||||
response: Applications.guard,
|
||||
status: [200, 400, 422],
|
||||
status: [200, 400, 422, 500],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
const { oidcClientMetadata, protectedAppMetadata, ...rest } = ctx.guard.body;
|
||||
|
|
|
@ -4,6 +4,7 @@ import { type Response } from 'got';
|
|||
import { type ZodType } from 'zod';
|
||||
|
||||
import assertThat from '../assert-that.js';
|
||||
import { consoleLog } from '../console.js';
|
||||
|
||||
import { type HandleResponse, cloudflareResponseGuard } from './types.js';
|
||||
|
||||
|
@ -18,6 +19,7 @@ const parseCloudflareResponse = (body: string) => {
|
|||
export const buildHandleResponse = (handleError: (statusCode: number) => never) => {
|
||||
const handleResponse: HandleResponse = <T>(response: Response<string>, guard?: ZodType<T>) => {
|
||||
if (!response.ok) {
|
||||
consoleLog.error('Cloudflare API error', response.statusCode, response.body);
|
||||
handleError(response.statusCode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue