Opened 15 years ago

Closed 14 years ago

#1807 closed Bugs (fixed)

boost::archive::xml_archive_exception does not store error code and reports wrong message text

Reported by: R. Brünner <rbruenner@…> Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.35.0 Severity: Problem
Keywords: xml_archive_exception what Cc:

Description

The code in the constructor for boost::archive::xml_archive_exception (basic_xml_archive.hpp) misses to store the error code value. Thus, a default constructed archive_exception is created with an error code of "no_exception".

The what() member function of xml_archive_exception therefore always reports the error "xml_archive_parsing_error" even if the true error reason is e. g. "xml_archive_tag_name_error". This happens because the enumeration constants "no_error" and "xml_archive_parsing_error" happen to both have the same integer value of 0.

Consequence:
After creating any object of type xml_archive_exception the information about the actual error is lost.

Suggestion:
1) The error enumerations for archive_exception and xml_archive_exception should be combined
2) The constructor should call archive_exception::archive_exception(exception_code)

OR

1) xml_archive_exception should have an exception_code member of its own where the constructor stores its argument
2) The xml_archive_exception::what() function should first check its own exception_code value and then hand over to the base class function, if no match is found.

Merging both exception classes would also be an option, though.

Thank you in advance for your assistance.

Change History (1)

comment:1 by Robert Ramey, 14 years ago

Resolution: fixed
Status: newclosed

OK - I made a change which I think will fix this.

Robert Ramey

Note: See TracTickets for help on using tickets.