Refactor error code from hasError to getError