lib/icu/Converter: Create() throws exception on error

This commit is contained in:
Max Kellermann
2016-04-12 22:18:36 +02:00
parent 33fdaa5b6d
commit 01b68db30e
9 changed files with 45 additions and 45 deletions

View File

@@ -40,19 +40,17 @@ static std::string fs_charset;
static IcuConverter *fs_converter;
bool
SetFSCharset(const char *charset, Error &error)
void
SetFSCharset(const char *charset)
{
assert(charset != nullptr);
assert(fs_converter == nullptr);
fs_converter = IcuConverter::Create(charset, error);
if (fs_converter == nullptr)
return false;
fs_converter = IcuConverter::Create(charset);
assert(fs_converter != nullptr);
FormatDebug(path_domain,
"SetFSCharset: fs charset is: %s", fs_charset.c_str());
return true;
}
#endif

View File

@@ -37,8 +37,11 @@ gcc_const
const char *
GetFSCharset();
bool
SetFSCharset(const char *charset, Error &error);
/**
* Throws std::runtime_error on error.
*/
void
SetFSCharset(const char *charset);
void
DeinitFSCharset();

View File

@@ -22,15 +22,13 @@
#include "Charset.hxx"
#include "config/ConfigGlobal.hxx"
bool
ConfigureFS(Error &error)
void
ConfigureFS()
{
#ifdef HAVE_FS_CHARSET
const char *charset = config_get_string(ConfigOption::FS_CHARSET);
return charset == nullptr || SetFSCharset(charset, error);
#else
(void)error;
return true;
if (charset != nullptr)
SetFSCharset(charset);
#endif
}

View File

@@ -26,9 +26,11 @@ class Error;
/**
* Performs global one-time initialization of this class.
*
* Throws std::runtime_error on error.
*/
bool
ConfigureFS(Error &error);
void
ConfigureFS();
void
DeinitFS();