Simplify the function, take a constructed Error object instead of reason + type. Let the caller to create the correct error object.