Skip to content

Use serialize-error module (Error#cause support) #2392

Closed as not planned
Closed as not planned
@fregante

Description

@fregante

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions