Refactor error()