libkazv
status-utils.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of libkazv.
3  * SPDX-FileCopyrightText: 2020-2024 tusooa <tusooa@kazv.moe>
4  * SPDX-License-Identifier: AGPL-3.0-or-later
5  */
6 
7 #pragma once
8 #include <libkazv-config.hpp>
9 #include <context.hpp>
10 #include <basejob.hpp>
11 
12 namespace Kazv
13 {
14  namespace detail
15  {
16  struct SimpleFailT
17  {
18  template<class Context>
19  EffectStatus operator()(Context &&) const {
20  return EffectStatus(/* succ = */ false);
21  };
22  };
23 
24  struct ReturnEffectStatusT
25  {
26  EffectStatus st;
27 
28  template<class Context>
29  EffectStatus operator()(Context &&) const
30  {
31  return st;
32  };
33  };
34  }
35 
39  constexpr auto simpleFail = detail::SimpleFailT{};
40 
44  detail::ReturnEffectStatusT failWithResponse(const BaseJob::Response &r);
45 
50  detail::ReturnEffectStatusT failEffect(std::string errorCode, std::string errorMsg);
51 }
::Kazv::Response Response
Definition: basejob.hpp:105
Definition: location.hpp:10
detail::ReturnEffectStatusT failEffect(std::string errorCode, std::string errorMsg)
An effect that returns a failed EffectStatus with the given error code and message.
Definition: status-utils.cpp:25
constexpr auto simpleFail
A effect that returns a failed EffectStatus upon invocation.
Definition: status-utils.hpp:39
ContextBase< DefaultRetType, A, D > Context
Definition: context.hpp:201
detail::ReturnEffectStatusT failWithResponse(const BaseJob::Response &r)
A effect that returns a failed EffectStatus upon invocation.
Definition: status-utils.cpp:12