loot / libloot

A C++ library for accessing LOOT's metadata and sorting functionality.
GNU General Public License v3.0
32 stars 12 forks source link

Error message for incorrect use of % #73

Open MacSplody opened 3 years ago

MacSplody commented 3 years ago

At the moment incorrect usage of % will display the following error.

ERROR: boost::bad_format_string: format-string is ill-formed

Working version:

  - &alreadyInX
    type: error
    content:
      - lang: en
        text: 'Delete. Already included in %1%.'
  - &alreadyInEnderalDLC
    <<: *alreadyInX
    subs: [ 'Enderal - Forgotten Stories.esm' ]
    condition: 'file("Enderal - Forgotten Stories.esm")'

Changes that will cause the error:

'Delete. Already included in 1%.' or 'Delete. Already included in %1.' or 'Delete. Already included in %1%%.'

So if possible we should show where the error is happening.

Ortham commented 3 years ago

This would have to be done in libloot, as the bad_format_string exception thrown has get_pos() and get_next() member functions, which are only useful in a context that also has the formatting string input. With them, we might be able to have errors like `format-string is ill-formed at "1%.", which is a little more useful.