Allow customizing return codes by error object or context