utils: update date/size parsing, factor out format
And update tests
This commit is contained in:
@ -76,6 +76,25 @@ Err(const Error& err)
|
||||
return tl::unexpected(err);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline tl::unexpected<Error>
|
||||
Err(const Result<T>& res)
|
||||
{
|
||||
return res.error();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
static inline Result<void>
|
||||
Ok(const T& t)
|
||||
{
|
||||
if (t)
|
||||
return Ok();
|
||||
else
|
||||
return Err(t.error());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* convenience
|
||||
@ -115,6 +134,9 @@ Err(Error::Code errcode, GError **err, const char* frm, ...)
|
||||
return Err(errcode, std::move(str));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define assert_valid_result(R) do { \
|
||||
if(!R) { \
|
||||
g_critical("error-result: %s", (R).error().what()); \
|
||||
|
||||
Reference in New Issue
Block a user