lib/icu: migrate from class Error to C++ exceptions

This commit is contained in:
Max Kellermann
2016-11-02 09:54:13 +01:00
parent e9c2885f34
commit 6d409d27ca
8 changed files with 23 additions and 88 deletions

View File

@@ -23,10 +23,9 @@
#ifdef HAVE_ICU
#include "Util.hxx"
#include "Error.hxx"
#include "util/AllocatedArray.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Error.hxx"
#include "util/RuntimeError.hxx"
#include <unicode/ucol.h>
#include <unicode/ustring.h>
@@ -53,21 +52,16 @@ static UCollator *collator;
#ifdef HAVE_ICU
bool
IcuCollateInit(Error &error)
void
IcuCollateInit()
{
assert(collator == nullptr);
assert(!error.IsDefined());
UErrorCode code = U_ZERO_ERROR;
collator = ucol_open("", &code);
if (collator == nullptr) {
error.Format(icu_domain, int(code),
"ucol_open() failed: %s", u_errorName(code));
return false;
}
return true;
if (collator == nullptr)
throw FormatRuntimeError("ucol_open() failed: %s",
u_errorName(code));
}
void