Extract error message logic and strings