Make strprintf
noexcept
. Improve the error message given on format string errors.
With this change large parts of the code base (strprintf
callers directly or indirectly) are switched from an implicit “might throw tinyformat::format_error
” to “will not throw” from a compiler/static analyzer perspective.
Also, reducing the number of unnecessary exceptions thrown increases the signal-to-noise for humans when analyzing potential issues introduced by uncaught exceptions.
These were the conditions that could make strprintf(…)
throw tinyformat::format_error
prior to this commit:
0$ git grep TINYFORMAT_ERROR
1src/tinyformat.h:// Error handling: Define TINYFORMAT_ERROR to customize the error handling for
2src/tinyformat.h:#define TINYFORMAT_ERROR(reasonString) throw tinyformat::format_error(reasonString)
3src/tinyformat.h:#ifndef TINYFORMAT_ERROR
4src/tinyformat.h:# define TINYFORMAT_ERROR(reason) assert(0 && reason)
5src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: Cannot convert from argument type to "
6src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: Not enough conversion specifiers in format string");
7src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: Not enough arguments to read variable width");
8src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: Not enough arguments to read variable precision");
9src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: the %a and %A conversion specs "
10src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: %n conversion spec not supported");
11src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: Conversion spec incorrectly "
12src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: Not enough format arguments");
13src/tinyformat.h: TINYFORMAT_ERROR("tinyformat: Too many conversion specifiers in format string");