tshaddix / webext-redux

A set of utilities for building Redux applications in Web Extensions.
MIT License
1.22k stars 179 forks source link

Pass complete serialized errors between background and proxy store #262

Open jlalmes opened 3 years ago

jlalmes commented 3 years ago

I've been facing the issue where webext-redux only allows you to error.message back to my content scripts in the case of an error in an aliased action. However my error objects contain other information, for example:

Error {
  message: 'this is a message',
  status: 400,
  code: 'CODE-001',
  result: { ... },
  stack: { ... },
}

This pull request will serialize all errors by default, the full error is then reconciled and rejected to the content-script that called the original dispatch function. You can test this PR with this npm module webext-redux-w-errors@latest.

First-time contributor, open to any feedback! 🙌

jlalmes commented 3 years ago

@tshaddix @vhmth - Hi guys seeking some guidance here. I am dispatching async actions with aliases and am therefore needing to return the full payload of a rejected error back to the content script via the proxy store. Are you happy to merge and publish this?