Reduce code duplication on process error handling