mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
refactor: use stand-alone getErrorShape
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
import type { H3Event } from 'h3'
|
import type { H3Event } from 'h3'
|
||||||
import { createError, defineEventHandler, getRequestURL, isMethod, readBody } from 'h3'
|
import { createError, defineEventHandler, getRequestURL, isMethod, readBody } from 'h3'
|
||||||
import type { TRPCResponse } from '@trpc/server/rpc'
|
import type { TRPCResponse } from '@trpc/server/rpc'
|
||||||
|
import { getErrorShape } from '@trpc/server/shared'
|
||||||
|
|
||||||
type MaybePromise<T> = T | Promise<T>
|
type MaybePromise<T> = T | Promise<T>
|
||||||
|
|
||||||
@@ -94,10 +95,11 @@ export function createNuxtApiHandler<TRouter extends AnyRouter> ({
|
|||||||
const path = getPath(event)
|
const path = getPath(event)
|
||||||
|
|
||||||
if (path === null) {
|
if (path === null) {
|
||||||
const error = router.getErrorShape({
|
const error = getErrorShape({
|
||||||
|
config: router._def._config,
|
||||||
error: new TRPCError({
|
error: new TRPCError({
|
||||||
message:
|
message:
|
||||||
'Param "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
|
'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
|
||||||
code: 'INTERNAL_SERVER_ERROR'
|
code: 'INTERNAL_SERVER_ERROR'
|
||||||
}),
|
}),
|
||||||
type: 'unknown',
|
type: 'unknown',
|
||||||
|
|||||||
Reference in New Issue
Block a user