diff options
author | Max Kellermann <max@musicpd.org> | 2017-12-19 11:55:52 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-12-19 11:56:29 +0100 |
commit | 3d960b5e556f5de9b3f7793d3b80b07cc981c631 (patch) | |
tree | e7f89541e42c0dbd707985de3dcd19fe481e3fa0 /src/util | |
parent | 39dc83bd82cd4c4c2b9db485f6f33af43548f21c (diff) |
util/RuntimeError: add FormatInvalidArgument()
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/RuntimeError.hxx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/util/RuntimeError.hxx b/src/util/RuntimeError.hxx index 8a3c86cb7..2d36d47ff 100644 --- a/src/util/RuntimeError.hxx +++ b/src/util/RuntimeError.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Max Kellermann <max.kellermann@gmail.com> + * Copyright (C) 2013-20157Max Kellermann <max.kellermann@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -44,4 +44,13 @@ FormatRuntimeError(const char *fmt, Args&&... args) noexcept return std::runtime_error(buffer); } +template<typename... Args> +inline std::invalid_argument +FormatInvalidArgument(const char *fmt, Args&&... args) noexcept +{ + char buffer[1024]; + snprintf(buffer, sizeof(buffer), fmt, std::forward<Args>(args)...); + return std::invalid_argument(buffer); +} + #endif |