Do not learn from rdstate() , badbit or failbit , but specifically what happened. Or, besides reading status flags, nothing is known about the threads?

  • The problem is that the place of a real error does not coincide with the place where the system found this error. For example, you read from cin double and int , and there actually is int and double . After reading double , you look fine, now you are reading int . He reads the whole part of the double written in reality, and also reports that everything is in order. Finally, you read another int , and it sees the decimal separator and throws an error. Do you see how far the cause is from the effect? - VladD
  • @VladD I specifically wanted to know if there was an opportunity to swear that they could not consider int, for example, and that everything fell down in this particular place. I understand that all this will have to be done with my hands? - borat_brata
  • if you are interested in format errors, it is better to divide the task into reading the line and its subsequent recognition. For example, read everything before a new line, and then return the returned line as a number, etc., to try to interpret. - jfs
  • @borat_brata: That's the thing. Well, you should have read double , but read int , where does the standard library recognize this from? Or there int should have been read, but you have some Tamil locale, and in it 1 not considered a digit. Well, it will tell you that it can not find the numbers in the string, how will this help? The system does not know if the source of the error is the wrong locale or the wrong type of read value, for example. - VladD

1 answer 1

Built-in basic tools that describe in detail the cause of the error - no.

What happened specifically depends on the function you are calling for the thread. But even here everything is not so simple, for example, open can return an error both in the absence of a file and in the absence of access to the file for reading, say. To learn more, you need to do a more comprehensive error analysis by means of system (and therefore platform-dependent) calls.

When working with files, the situation may change to include the filesystem library in the C ++ Standard.

  • “more comprehensive error analysis” —can an example? For simplicity, you can limit Unix, where the open system call can expose a couple dozen different errno values. I think the author's question can be interpreted as: does the portable c ++ API provide a higher level access to these details? - jfs
  • The @jfs in question is about std::*stream , and the member function open from there, not the system open . - αλεχολυτ
  • I know. Why do you think I mentioned: "Does a higher level portable c ++ API provide access to these details." - jfs
  • @jfs judging by the comments on the question of the vehicle, you just need to read numbers of different types. A portable API will appear when the filesystem is included in the Standard. - αλεχολυτ
  • one
    the question (see the title) is whether useful details about the error, such as those provided by the system open, can be extracted from the already existing API (iostream — see the contents of the question). - jfs