Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic_ios::clear: iostream error #143

Closed
pauljurczak opened this issue Jun 4, 2023 · 4 comments
Closed

basic_ios::clear: iostream error #143

pauljurczak opened this issue Jun 4, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@pauljurczak
Copy link

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
@pauljurczak pauljurczak added the bug Something isn't working label Jun 4, 2023
@pauljurczak
Copy link
Author

Never mind. The file path was wrong. Perhaps, a more informative exception message would be in order?

@d99kris
Copy link
Owner

d99kris commented Jun 5, 2023

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.

@pauljurczak
Copy link
Author

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. :-)

@d99kris
Copy link
Owner

d99kris commented Jun 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants