Fixed the error type checking.