score:0

given that you have a react project that has several modules mainly for:

  • user
  • blog
  • comments

in your action you can do something like this:

// actions/user.js
export const usermessageerror = (payload, message) => {
    type: 'user_err_message',
    error: {
       message,
       payload
    },
}

you can actually place some error handling case inside of each of the module's reducer like so:

// reducer/user.js

case 'user_err_message':
// you might want to set the request payload and the error message
// to the state in order for you to actually know what's going on
//
// then you could have a toast or a modal in the container or inside
// your component to actually display the actual error message

doing this, you can actually know which module returns an error, what the payload is and actually getting the error message.

you might not need the payload to be returned, but it is all up to you and your preference.


Related Query

More Query from same tag