summaryrefslogtreecommitdiff
path: root/src/fs/AllocatedPath.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-04-12 21:24:16 +0200
committerMax Kellermann <max@duempel.org>2016-04-21 14:23:55 +0200
commit6513ff92a7012819db464adad094b69e8b585127 (patch)
tree1f4657391f9505f145abdbcca05bbb5d7c331d9d /src/fs/AllocatedPath.cxx
parenta0eb6d0976e5b5136769341f3bb3a03d096be46c (diff)
fs/Charset: throw exception on error
Diffstat (limited to 'src/fs/AllocatedPath.cxx')
-rw-r--r--src/fs/AllocatedPath.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/fs/AllocatedPath.cxx b/src/fs/AllocatedPath.cxx
index 62284715a..eda4008da 100644
--- a/src/fs/AllocatedPath.cxx
+++ b/src/fs/AllocatedPath.cxx
@@ -24,6 +24,8 @@
#include "util/Error.hxx"
#include "Compiler.h"
+#include <stdexcept>
+
/* no inlining, please */
AllocatedPath::~AllocatedPath() {}
@@ -31,7 +33,11 @@ AllocatedPath
AllocatedPath::FromUTF8(const char *path_utf8)
{
#if defined(HAVE_FS_CHARSET) || defined(WIN32)
- return AllocatedPath(::PathFromUTF8(path_utf8));
+ try {
+ return AllocatedPath(::PathFromUTF8(path_utf8));
+ } catch (const std::runtime_error &) {
+ return nullptr;
+ }
#else
return FromFS(path_utf8);
#endif
@@ -58,7 +64,11 @@ AllocatedPath::GetDirectoryName() const
std::string
AllocatedPath::ToUTF8() const
{
- return ::PathToUTF8(c_str());
+ try {
+ return ::PathToUTF8(c_str());
+ } catch (const std::runtime_error &) {
+ return std::string();
+ }
}
void