I noticed that RTK’s error serialization is rather simple:
|
export const miniSerializeError = (value: any): SerializedError => { |
|
if (typeof value === 'object' && value !== null) { |
|
const simpleError: SerializedError = {} |
|
for (const property of commonProperties) { |
|
if (typeof value[property] === 'string') { |
|
simpleError[property] = value[property] |
|
} |
|
} |
|
|
|
return simpleError |
|
} |
|
|
|
return { message: String(value) } |
|
} |
For example this does not support nested errors, like the new cause property: https://v8.dev/features/error-cause
I know RTK supports specifying a custom serializeError as an option, but it'd be great to support the cause property out of the box, perhaps using an existing solution for error serialization:
I noticed that RTK’s error serialization is rather simple:
redux-toolkit/packages/toolkit/src/createAsyncThunk.ts
Lines 94 to 107 in 64a30d8
For example this does not support nested errors, like the new
causeproperty: https://v8.dev/features/error-causeI know RTK supports specifying a custom
serializeErroras an option, but it'd be great to support thecauseproperty out of the box, perhaps using an existing solution for error serialization: