Problem or motivation
There is no mention in the docs how we could use EvlogError with Tanstack Start Server Functions. It seems to be common practice to just throw from these functions. However, when throwing an EvlogError properties like why and fix are not sent to the client. By default, errors are sent just with the message property.
Proposed feature
We could document the use of createSerializationAdapter and add it to the examples. This function allows us to define custom types that can be serialized. I've added something like this to src/start.ts and it's been working fine.
import { createSerializationAdapter } from '@tanstack/react-router'
import { createStart } from '@tanstack/react-start'
import { createError, EvlogError, parseError } from 'evlog'
const evlogErrorAdapter = createSerializationAdapter({
key: 'EvlogError',
test: (error: unknown): error is EvlogError => error instanceof EvlogError,
toSerializable: (error) => {
const { raw, ...rest } = parseError(error)
return rest
},
fromSerializable: (value) => createError(value)
})
export const startInstance = createStart(() => {
return {
serializationAdapters: [evlogErrorAdapter]
}
})
It is worth noting that these adapters are not yet documented.
Possible implementation (optional)
No response
Alternatives you’ve considered (optional)
No response
Problem or motivation
There is no mention in the docs how we could use
EvlogErrorwith Tanstack Start Server Functions. It seems to be common practice to justthrowfrom these functions. However, when throwing anEvlogErrorproperties likewhyandfixare not sent to the client. By default, errors are sent just with themessageproperty.Proposed feature
We could document the use of
createSerializationAdapterand add it to the examples. This function allows us to define custom types that can be serialized. I've added something like this tosrc/start.tsand it's been working fine.It is worth noting that these adapters are not yet documented.
Possible implementation (optional)
No response
Alternatives you’ve considered (optional)
No response