Menu

#162 Throwing std::runtime_error in stringhelper-iconv.cxx

v1.1.x
closed
iconv (1)
5
2013-04-15
2013-03-11
Psychon
No

Hi,

iconv_handle in stringhelper-iconv.cxx throws a runtime_error if iconv_open() or iconv_close() fail. IMHO this is bad style in a library that is used in other code. Instead, just printing the error (and perhaps mentioning "log4cplus" in the error message) would mean the app can survive this problem.

Also, iconv_conv() checks if cvt.handle == iconv_error_handle in line 157. Due to the above exception this is dead code, because the constructor would have thrown an exception if iconv_open() failed. Personally, I prefer the way that iconv_conv() deals with this problem over the exception.

(This was found via cppcheck which complained that destructors should not throw exceptions)

Thanks,
Uli

Discussion

  • Václav Haisman

    Václav Haisman - 2013-03-11
    • labels: --> iconv
    • assigned_to: Václav Zeman
     
  • Václav Haisman

    Václav Haisman - 2013-03-11

    Thank you for the bug report. I have applied the attached patch to fix the issue of an exception escaping from dtor.

     
  • Václav Haisman

    Václav Haisman - 2013-04-15
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.