Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F325781
status-utils.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
status-utils.hpp
View Options
/*
* This file is part of libkazv.
* SPDX-FileCopyrightText: 2020 Tusooa Zhu <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include
<context.hpp>
namespace
Kazv
{
namespace
detail
{
struct
SimpleFailT
{
template
<
class
Context
>
EffectStatus
operator
()(
Context
&&
)
const
{
return
EffectStatus
(
/* succ = */
false
);
};
};
}
/**
* A effect that returns a failed EffectStatus upon invocation.
*/
constexpr
auto
simpleFail
=
detail
::
SimpleFailT
{};
/**
* A effect that returns a failed EffectStatus upon invocation.
*/
template
<
class
Resp
>
constexpr
auto
failWithResponse
(
Resp
&&
r
)
{
auto
code
=
r
.
errorCode
();
auto
msg
=
std
::
forward
<
Resp
>
(
r
).
errorMessage
();
auto
d
=
json
{
{
"error"
,
msg
},
{
"errorCode"
,
code
},
};
return
[
data
=
JsonWrap
(
d
)](
auto
&&
)
{
return
EffectStatus
(
/* succ = */
false
,
data
);
};
}
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Thu, Apr 24, 4:23 AM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
87282
Default Alt Text
status-utils.hpp (1 KB)
Attached To
Mode
rL libkazv
Attached
Detach File
Event Timeline
Log In to Comment