File: client_error.h

package info (click to toggle)
uhd 3.13.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 207,120 kB
  • sloc: cpp: 167,245; ansic: 86,841; vhdl: 53,420; python: 40,839; xml: 13,167; tcl: 5,688; makefile: 2,167; sh: 1,719; pascal: 230; csh: 94; asm: 20; perl: 11
file content (39 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#ifndef RPC_CLIENT_ERROR_H
#define RPC_CLIENT_ERROR_H

#include <stdexcept>
#include <cstdint>

namespace rpc {
namespace detail {

//! \brief Describes an error that is the result of a connected client
//! doing something unexpected (e.g. calling a function that does not exist,
//! wrong number of arguments, etc.)
class client_error : public std::exception {
public:
    //! \brief Error codes used for signaling back to clients. These are used
    //! to produce google-able error messages (since the msgpack-rpc protocol
    //! does not define error handling in any more detail than sending an
    //! object).
    //! \note Care must be taken to keep these codes stable even between major
    //! versions.
    enum class code : uint16_t {
        no_such_function = 1,
        wrong_arity = 2,
        protocol_error = 4
    };

    client_error(code c, const std::string &msg);

    const char *what() const noexcept;

private:
    std::string what_;
};
}
}

#endif // RPC_CLIENT_ERROR_H