File: exception.hpp

package info (click to toggle)
tilemaker 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 78,284 kB
  • sloc: cpp: 28,715; ansic: 4,052; makefile: 180; ruby: 77; sh: 6
file content (134 lines) | stat: -rw-r--r-- 3,288 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef VTZERO_EXCEPTION_HPP
#define VTZERO_EXCEPTION_HPP

/*****************************************************************************

vtzero - Tiny and fast vector tile decoder and encoder in C++.

This file is from https://github.com/mapbox/vtzero where you can find more
documentation.

*****************************************************************************/

/**
 * @file exception.hpp
 *
 * @brief Contains the exceptions used in the vtzero library.
 */

#include <cstdint>
#include <stdexcept>
#include <string>

namespace vtzero {

    /**
     * Base class for all exceptions directly thrown by the vtzero library.
     */
    class exception : public std::runtime_error {

    public:

        /// Constructor
        explicit exception(const char* message) :
            std::runtime_error(message) {
        }

        /// Constructor
        explicit exception(const std::string& message) :
            std::runtime_error(message) {
        }

    }; // class exception

    /**
     * This exception is thrown when vector tile encoding isn't valid according
     * to the vector tile specification.
     */
    class format_exception : public exception {

    public:

        /// Constructor
        explicit format_exception(const char* message) :
            exception(message) {
        }

        /// Constructor
        explicit format_exception(const std::string& message) :
            exception(message) {
        }

    }; // class format_exception

    /**
     * This exception is thrown when a geometry encoding isn't valid according
     * to the vector tile specification.
     */
    class geometry_exception : public format_exception {

    public:

        /// Constructor
        explicit geometry_exception(const char* message) :
            format_exception(message) {
        }

        /// Constructor
        explicit geometry_exception(const std::string& message) :
            format_exception(message) {
        }

    }; // class geometry_exception

    /**
     * This exception is thrown when a property value is accessed using the
     * wrong type.
     */
    class type_exception : public exception {

    public:

        /// Constructor
        explicit type_exception() :
            exception("wrong property value type") {
        }

    }; // class type_exception

    /**
     * This exception is thrown when an unknown version number is found in the
     * layer.
     */
    class version_exception : public exception {

    public:

        /// Constructor
        explicit version_exception(const uint32_t version) :
            exception(std::string{"unknown vector tile version: "} +
                      std::to_string(version)) {
        }

    }; // version_exception

    /**
     * This exception is thrown when an index into the key or value table
     * in a layer is out of range. This can only happen if the tile data is
     * invalid.
     */
    class out_of_range_exception : public exception {

    public:

        /// Constructor
        explicit out_of_range_exception(const uint32_t index) :
            exception(std::string{"index out of range: "} +
                      std::to_string(index)) {
        }

    }; // out_of_range_exception

} // namespace vtzero

#endif // VTZERO_EXCEPTION_HPP