Which pattern is suitable for this scenario?
I would like to refactor some code of a process that must perform a processing. The processing involves several steps, each of which can fail or go well. If successful, it must proceed to the next step. At each step I need to save a state. Each step performs different types of operations (for example, rest calls, validations, etc.). Can the chain of responsibility pattern be suitable for this scenario? Alternatively, what pattern could I use? If the chain of responsibility pattern were suitable, must the check method necessarily provide a boolean output or can it use an exception to block the chain? Thanks in advance to anyone who can help me resolve this doubt Is it correct to use a context object to transfer data between the pieces of the chain?

I would like to refactor some code of a process that must perform a processing. The processing involves several steps, each of which can fail or go well. If successful, it must proceed to the next step. At each step I need to save a state. Each step performs different types of operations (for example, rest calls, validations, etc.).
Can the chain of responsibility pattern be suitable for this scenario? Alternatively, what pattern could I use?
If the chain of responsibility pattern were suitable, must the check method necessarily provide a boolean output or can it use an exception to block the chain?
Thanks in advance to anyone who can help me resolve this doubt Is it correct to use a context object to transfer data between the pieces of the chain?