C++Guns – RoboBlog

08.07.2019

C++ Guns: std::ofstream better err msg

Filed under: Allgemein — Tags: — Thomas @ 20:07

Folgender Fetzen Code gibt eine gescheite Fehlermeldung für streams (wann fixen die endlich streams & exceptions?)

    auto fileName = std::string(getenv("HOME")) + "/config/clusterprocessaccounting.dat";
    std::ofstream f(fileName);
    if(not f) throw std::system_error(errno, std::system_category(), "failed to open " + fileName + " ");

terminate called after throwing an instance of 'std::system_error'
what(): failed to open /home/ite/config/clusterprocessaccounting.dat : No such file or directory

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress