basic_ios::clear: iostream error
pauljurczak opened this issue · comments
This test program:
#include "rapidcsv.h"
int main() {
rapidcsv::Document doc("ex.csv");
}
with this ex.csv
file:
Open,High,Low,Close,Volume,Adj Close
64.529999,64.800003,64.139999,64.620003,21705200,64.620003
64.419998,64.730003,64.190002,64.620003,20235200,64.620003
64.330002,64.389999,64.050003,64.360001,19259700,64.360001
64.610001,64.949997,64.449997,64.489998,19384900,64.489998
64.470001,64.690002,64.300003,64.620003,21234600,64.620003
and this CMakeLists.txt
:
cmake_minimum_required(VERSION 3.19)
project(wave LANGUAGES CXX)
add_executable(wave main.cpp)
target_compile_options(wave PRIVATE -O3 -Wno-narrowing)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
set_property(TARGET wave PROPERTY CXX_STANDARD 20)
on Ubuntu 22.04.2 with gcc 11.3 or gcc 12.1, produces this exception:
terminate called after throwing an instance of 'std::__ios_failure'
what(): basic_ios::clear: iostream error
Never mind. The file path was wrong. Perhaps, a more informative exception message would be in order?
Good to hear you found the issue!
As for the exception (message), rapidcsv uses original / underlying c++ standard library exceptions where applicable. So you would get the same exception if you would do something like this:
std::ifstream file;
file.exceptions(std::ifstream::badbit | std::ifstream::failbit);
file.open("doesnotexist.txt");
Rapidcsv simply lets the standard exception through without catching it, this is deliberate.
I was also trying Vince's CSV Parser (https://github.com/vincentlaucsb/csv-parser) and he catches this exception and rethrows it with a more meaningful message. Just an idea. Not a big problem. :-)
Ok, thanks for sharing. Yes it's a viable approach, but I think rapidcsv will stick with its current approach.
Anyways, it's good you reported a github issue, so that others googling the error might find this thread.