My app usually operates with plain javascript objects, but sometimes it has to throw errors. I widely use stores with useContextProvider / useContext, and
const store = useContext(SOME_STORE) // store.data can be either a plain javascript object or a CustomError('something')
Qwik complains about the store:
Seems like you are referencing "store" inside a different scope (useTask$), when this happens, Qwik needs to serialize the value, however, "store.value.data" is an instance of the "CustomError" class, which is not serializable. Use a simple object literal instead.
What should I add to the definition of CustomError class so that it becomes serializable? It already has toJSON method.
Is there any example of a custom serializable class that is supported by Qwik?