cpp-msgpack-rpc
0.2.0
An RPC library implementing MessagePack RPC.
Toggle main menu visibility
Loading...
Searching...
No Matches
method_exception.h
Go to the documentation of this file.
1
/*
2
* Copyright 2023 MusicScience37 (Kenta Kabashima)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
20
#pragma once
21
22
#include <exception>
23
#include <memory>
24
#include <type_traits>
25
#include <utility>
26
27
#include <msgpack.hpp>
28
29
#include "msgpack_rpc/impl/msgpack_rpc_export.h"
30
31
namespace
msgpack_rpc::methods
{
32
39
class
MSGPACK_RPC_EXPORT
MethodException
:
public
std::exception {
40
public
:
41
// Exceptions must be exported in libraries. If not exported, exceptions
42
// cannot be caught correctly.
43
53
template
<
typename
T>
54
explicit
MethodException
(T&&
object
,
55
std::enable_if_t<!std::is_same_v<std::decay_t<T>,
MethodException
>,
56
void
*>
/*for SFINAE*/
57
=
nullptr
)
58
:
zone_
(
std
::make_shared<msgpack::zone>()),
59
object_
(
std
::forward<T>(
object
), *
zone_
) {}
60
66
[[nodiscard]]
const
msgpack::object& object() const noexcept;
67
73
[[nodiscard]] const
char
* what() const noexcept override;
74
78
MethodException
(const
MethodException
&) noexcept;
79
83
MethodException
(
MethodException
&&) noexcept;
84
90
MethodException
& operator=(const
MethodException
&) noexcept;
91
97
MethodException
& operator=(
MethodException
&&) noexcept;
98
100
~
MethodException
() noexcept override;
101
102
private:
104
std
::shared_ptr<msgpack::zone>
zone_
;
105
107
msgpack::
object
object_
;
108
};
109
110
}
// namespace msgpack_rpc::methods
msgpack_rpc::methods::MethodException::zone_
std::shared_ptr< msgpack::zone > zone_
Zone in msgpack library.
Definition
method_exception.h:104
msgpack_rpc::methods::MethodException::object_
msgpack::object object_
Object in msgpack library.
Definition
method_exception.h:107
msgpack_rpc::methods::MethodException::object
const msgpack::object & object() const noexcept
Get the object in msgpack library.
Definition
method_exception.cpp:24
msgpack_rpc::methods::MethodException::MethodException
MethodException(T &&object, std::enable_if_t<!std::is_same_v< std::decay_t< T >, MethodException >, void * >=nullptr)
Constructor.
Definition
method_exception.h:54
msgpack_rpc::methods
Namespace of methods in MessagePack-RPC.
Definition
functional_method.h:41
std
STL namespace.
include
msgpack_rpc
methods
method_exception.h
Generated on
for cpp-msgpack-rpc by
1.18.0