loot/libloot

Error message for incorrect use of %

MacSplody opened this issue · 1 comments

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.

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.