T
TanStack3w ago
correct-apricot

customErrorAdapter

I have this errors.ts which i want to create my own custom errors, but where do i put my customErrorAdapter? import { createSerializationAdapter } from "@tanstack/react-router" export class NotMemberError extends Error { public foo: string public bar: bigint constructor(message: string, options: { foo: string; bar: bigint }) { super(message) Object.setPrototypeOf(this, new.target.prototype) this.name = this.constructor.name this.foo = options.foo this.bar = options.bar } } export const customErrorAdapter = createSerializationAdapter({ key: "custom-error", test: (v) => v instanceof NotMemberError, toSerializable: ({ message, foo, bar }) => { return { message, foo, bar, } }, fromSerializable: ({ message, foo, bar }) => { return new NotMemberError(message, { foo, bar }) }, })
3 Replies
national-gold
national-gold3w ago
GitHub
router/e2e/react-start/serialization-adapters/src/start.tsx at main...
🤖 A client-first, server-capable, fully type-safe router and full-stack framework for the web (React and more). - TanStack/router
correct-apricot
correct-apricotOP3w ago
Aha, so I have to create this start.tsx file, since it does not exist
national-gold
national-gold3w ago
Correct

Did you find this page helpful?