hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.11k stars 362 forks source link

Improve exception error messages #109

Open muesli4 opened 6 years ago

muesli4 commented 6 years ago

Proposed improvement to https://github.com/hyperrealm/libconfig/issues/108. Let me know what you think about it or if that's something you don't want to change.

ilyapopov commented 5 years ago

Maybe it is better to just derive from std::runtime_error. This way you get wgat() etc. for free.

muesli4 commented 5 years ago

Maybe it is better to just derive from std::runtime_error. This way you get wgat() etc. for free.

The thing is that the existing code is not really composable in a way that makes refactoring easy. Is C++11 allowed? If so I can make it work with std::runtime_error (because I require constructor delegation).

muesli4 commented 5 years ago

I updated the exception classes to inherit from std::runtime_error. The examples seem to work and the tests pass. I can condense this into one commit.

muesli4 commented 4 years ago

I rebased my changes on the recent version and it is only one commit now.

muesli4 commented 4 years ago

I deliberately caused some of the errors:

> mpd-touch-screen-gui
mpd-touch-screen-gui 0.0.1
Found configuration file: /home/moritz/.config/mpd-touch-screen-gui/program.conf
setting not found exception: program.[default_font]
> mpd-touch-screen-gui
mpd-touch-screen-gui 0.0.1
Found configuration file: /home/moritz/.config/mpd-touch-screen-gui/program.conf
setting type exception: program.default_font.path
> mpd-touch-screen-gui
mpd-touch-screen-gui 0.0.1
Found configuration file: /home/moritz/.config/mpd-touch-screen-gui/program.conf
parse exception: in /home/moritz/.config/mpd-touch-screen-gui/program.conf, at line 6: syntax error
> mpd-touch-screen-gui
mpd-touch-screen-gui 0.0.1
Found configuration file: /home/moritz/.config/mpd-touch-screen-gui/program.conf
parse exception: in /home/moritz/.config/mpd-touch-screen-gui/program.conf, at line 6: duplicate setting name
muesli4 commented 4 years ago

Is there anything I can improve or change such that this will be merged?

muesli4 commented 1 year ago

It has been a long time but I took I few minutes trying to get this done. So, I guess better late than never. Let me know if you want anything changed (even small details).