Issue Details (XML | Word | Printable)

Key: STDCXX-229
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Martin Sebor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

better iostreams exception error messages

Created: 29/Jun/06 01:34 AM   Updated: 02/Jun/08 07:16 PM
Return to search
Component/s: 18. Language Support, 19. Diagnostics
Affects Version/s: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
Fix Version/s: 4.3.0

Time Tracking:
Original Estimate: 40h
Original Estimate - 40h
Remaining Estimate: 40h
Remaining Estimate - 40h
Time Spent: Not Specified
Remaining Estimate - 40h

Environment: all

Severity: Usability


 Description  « Hide
***Created By: sebor @ Apr 24, 2001 12:11:59 PM***
Subject: better exception error messages (by using CRTL's strerror()?) (1601)
Date: Tue, 24 Apr 2001 10:57:13 -0400
From: cxxrtl@cxxc.zko.dec.com
To: OEMSUPPORT@roguewave.com

A customer requested that the what() string for a standard iostream
error be more descriptive, possibly by using the strerror() or
perror() function to return the underlying CRTL error string...

Example:

#define __USE_STD_IOSTREAM
#include <fstream>
#include <string>

int main() {
try { std::ofstream out; out.exceptions(std::ios_base::badbit); out.open("#3.2_BLUE_%.LinkedText"); out << "Hello!" << std::endl; }
catch (std::exception& e) { perror("The funny looking name that isn't in scope anymore"); std::cerr << e.what(); }
}
------------------------------- test.cxx -------------------------------

$ run test
The funny looking name that isn't in scope anymore: non-translatable vms
error code: 0x186D4 %rms-f-syn, file specification syntax error
iostream object has failbit set

***Modified By: sebor @ Sep 29, 2003 11:44:10 AM***
This would be quite useful but it's non trivial to do in iostreams where exceptions are thrown from stream classes but errors of interest typically occur in stream buffers. Once possibility is to selectively capture and save errno in a thread-safe way (so that it can be later modified w/o affecting the recorded cause of the original error) when it occurs during libc and system calls made from streambuf members and later retrieve it when an exception is about to be thrown from the stream class.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Sebor added a comment - 26/Aug/07 11:58 PM
Added 4.1.4 to affected versions. Deferred for 4.3 (or possibly later). We might want to consider N2303 when designing this:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2303.html

Martin Sebor added a comment - 02/Dec/07 11:35 PM
A common request is to add the stack trace at the call site to the exception what() string. See, for example, the following gcc enhancement request: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33903

Martin Sebor added a comment - 02/Dec/07 11:36 PM
Added 4.2.0 to the list of Affected Versions and set Severity to Cosmetic.

Martin Sebor added a comment - 02/Jun/08 07:14 PM
See N2629 for a proposal for an enhancement that would make this possible in front of the committee.

Martin Sebor added a comment - 02/Jun/08 07:16 PM
Set initial estimate.