Extract common exception functionality into module