| Tilt Five NDK |

errors.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020-2022 Tilt Five, Inc.
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 */
16
17#pragma once
18
21
22#include "errors.h"
23
24#include <system_error>
25
26 namespace tiltfive {
27
29// Error //
31
35
37 enum class Error {
38 // --------- C Errors ---------
40 kSuccess = T5_SUCCESS,
41
43 kTimeout = T5_TIMEOUT,
44
46 //
49 kNoContext = T5_ERROR_NO_CONTEXT,
50
52 kLibraryUnavailable = T5_ERROR_NO_LIBRARY,
53
55 kInternalError = T5_ERROR_INTERNAL,
56
58 kNoService = T5_ERROR_NO_SERVICE,
59
61 kIoFailure = T5_ERROR_IO_FAILURE,
62
64 kRequestIdUnknown = T5_ERROR_REQUEST_ID_UNKNOWN,
65
67 kInvalidArgument = T5_ERROR_INVALID_ARGS,
68
70 kDeviceLost = T5_ERROR_DEVICE_LOST,
71
73 kTargetNotFound = T5_ERROR_TARGET_NOT_FOUND,
74
76 kInvalidState = T5_ERROR_INVALID_STATE,
77
79 kSettingUnknown = T5_ERROR_SETTING_UNKNOWN,
80
82 kSettingWrongType = T5_ERROR_SETTING_WRONG_TYPE,
83
85 kMiscRemote = T5_ERROR_MISC_REMOTE,
86
88 kOverflow = T5_ERROR_OVERFLOW,
89
91 kGfxApiUnavailable = T5_ERROR_GRAPHICS_API_UNAVAILABLE,
92
94 kUnsupported = T5_ERROR_UNSUPPORTED,
95
97 kDecodeError = T5_ERROR_DECODE_ERROR,
98
100 kInvalidGfxContext = T5_ERROR_INVALID_GFX_CONTEXT,
101
103 kGfxContextInitFail = T5_ERROR_GFX_CONTEXT_INIT_FAIL,
104
106 kTryAgain = T5_ERROR_TRY_AGAIN,
107
109 kUnavailable = T5_ERROR_UNAVAILABLE,
110
112 kAlreadyConnected = T5_ERROR_ALREADY_CONNECTED,
113
115 kNotConnected = T5_ERROR_NOT_CONNECTED,
116
118 kStringOverflow = T5_ERROR_STRING_OVERFLOW,
119
121 kServiceIncompatible = T5_ERROR_SERVICE_INCOMPATIBLE,
122
124 kPermissionDenied = T5_PERMISSION_DENIED,
125
127 kInvalidBuffer = T5_ERROR_INVALID_BUFFER_SIZE,
128};
129
131
132 namespace details {
133
134// Work around the lack of inline variable support.
135 template <typename Dummy>
136 struct ErrorCategory : std::error_category {
137 [[nodiscard]] auto name() const noexcept -> const char* override {
138 return "Tilt Five Error";
139 }
140
141 [[nodiscard]] auto message(int ev) const -> std::string override {
142 return ::t5GetResultMessage(static_cast<T5_Result>(ev));
143 }
144
145 static const ErrorCategory kSingleton;
146};
147
148 template <typename Dummy>
149 const ErrorCategory<Dummy> ErrorCategory<Dummy>::kSingleton;
150
151} // namespace details
152
153 using ErrorCategory = details::ErrorCategory<void>;
154
155 inline std::error_code make_error_code(Error e) noexcept {
156 return {static_cast<int>(e), ErrorCategory::kSingleton};
157}
158
159} // namespace tiltfive
160
161 namespace std {
162
163 template <>
164 struct is_error_code_enum<tiltfive::Error> : true_type {};
165
166} // namespace std
errors.h
C errors for the Tilt Five™ API.
T5_Result
uint32_t T5_Result
Represents an error code that may be returned by the Tilt Five™ API.
Definition: errors.h:47
T5_ERROR_MISC_REMOTE
#define T5_ERROR_MISC_REMOTE
Miscellaneous remote error.
Definition: errors.h:99
T5_ERROR_DECODE_ERROR
#define T5_ERROR_DECODE_ERROR
Failed to decode.
Definition: errors.h:111
T5_ERROR_INTERNAL
#define T5_ERROR_INTERNAL
An internal error occurred.
Definition: errors.h:69
T5_ERROR_TRY_AGAIN
#define T5_ERROR_TRY_AGAIN
Target is not currently available.
Definition: errors.h:120
T5_ERROR_GFX_CONTEXT_INIT_FAIL
#define T5_ERROR_GFX_CONTEXT_INIT_FAIL
Failed to initialize graphics context.
Definition: errors.h:117
T5_ERROR_INVALID_ARGS
#define T5_ERROR_INVALID_ARGS
Argument(s) are invalid.
Definition: errors.h:81
T5_ERROR_NOT_CONNECTED
#define T5_ERROR_NOT_CONNECTED
The target is not connected.
Definition: errors.h:129
T5_ERROR_UNAVAILABLE
#define T5_ERROR_UNAVAILABLE
Target is unavailable.
Definition: errors.h:123
T5_ERROR_INVALID_BUFFER_SIZE
#define T5_ERROR_INVALID_BUFFER_SIZE
Invalid Buffer Size.
Definition: errors.h:141
T5_ERROR_SERVICE_INCOMPATIBLE
#define T5_ERROR_SERVICE_INCOMPATIBLE
Service incompatible.
Definition: errors.h:135
T5_TIMEOUT
#define T5_TIMEOUT
Timeout.
Definition: errors.h:57
T5_ERROR_STRING_OVERFLOW
#define T5_ERROR_STRING_OVERFLOW
Overflow during string conversion operation.
Definition: errors.h:132
T5_ERROR_SETTING_UNKNOWN
#define T5_ERROR_SETTING_UNKNOWN
The requested param is unknown.
Definition: errors.h:93
T5_ERROR_REQUEST_ID_UNKNOWN
#define T5_ERROR_REQUEST_ID_UNKNOWN
Service doesn't understand the request.
Definition: errors.h:78
T5_ERROR_DEVICE_LOST
#define T5_ERROR_DEVICE_LOST
Device lost.
Definition: errors.h:84
t5GetResultMessage
T5_EXPORT const char * t5GetResultMessage(T5_Result result)
T5_ERROR_SETTING_WRONG_TYPE
#define T5_ERROR_SETTING_WRONG_TYPE
The requested param has a different type to the requested type.
Definition: errors.h:96
T5_ERROR_NO_SERVICE
#define T5_ERROR_NO_SERVICE
Service isn't connected.
Definition: errors.h:72
T5_ERROR_UNSUPPORTED
#define T5_ERROR_UNSUPPORTED
Action is unsupported.
Definition: errors.h:108
T5_ERROR_IO_FAILURE
#define T5_ERROR_IO_FAILURE
Misc IO failure.
Definition: errors.h:75
T5_ERROR_ALREADY_CONNECTED
#define T5_ERROR_ALREADY_CONNECTED
The target is already connected.
Definition: errors.h:126
T5_ERROR_NO_CONTEXT
#define T5_ERROR_NO_CONTEXT
No context.
Definition: errors.h:63
T5_PERMISSION_DENIED
#define T5_PERMISSION_DENIED
Permission denied.
Definition: errors.h:138
T5_ERROR_NO_LIBRARY
#define T5_ERROR_NO_LIBRARY
No library loaded.
Definition: errors.h:66
T5_SUCCESS
#define T5_SUCCESS
Success.
Definition: errors.h:54
T5_ERROR_TARGET_NOT_FOUND
#define T5_ERROR_TARGET_NOT_FOUND
Target (wand) not found.
Definition: errors.h:87
T5_ERROR_OVERFLOW
#define T5_ERROR_OVERFLOW
Buffer overflow.
Definition: errors.h:102
T5_ERROR_GRAPHICS_API_UNAVAILABLE
#define T5_ERROR_GRAPHICS_API_UNAVAILABLE
Specified graphics API is unavailable.
Definition: errors.h:105
T5_ERROR_INVALID_GFX_CONTEXT
#define T5_ERROR_INVALID_GFX_CONTEXT
Graphics context is invalid.
Definition: errors.h:114
T5_ERROR_INVALID_STATE
#define T5_ERROR_INVALID_STATE
Incorrect state for the request.
Definition: errors.h:90
tiltfive::Error
Error
Error codes returned by most functions of return type Result.
Definition: errors.hpp:37
tiltfive::Error::kRequestIdUnknown
@ kRequestIdUnknown
Service doesn't understand the request.
tiltfive::Error::kStringOverflow
@ kStringOverflow
String overflow.
tiltfive::Error::kServiceIncompatible
@ kServiceIncompatible
Service incompatible.
tiltfive::Error::kSettingWrongType
@ kSettingWrongType
The requested param has a different type to the requested type.
tiltfive::Error::kLibraryUnavailable
@ kLibraryUnavailable
Library Unavailable.
tiltfive::Error::kAlreadyConnected
@ kAlreadyConnected
Target is already connected.
tiltfive::Error::kTryAgain
@ kTryAgain
Target is temporarily unavailable.
tiltfive::Error::kGfxApiUnavailable
@ kGfxApiUnavailable
Specified graphics API is unavailable.
tiltfive::Error::kNotConnected
@ kNotConnected
Target is not connected.
tiltfive::Error::kSettingUnknown
@ kSettingUnknown
The requested param is unknown.
tiltfive::Error::kNoContext
@ kNoContext
No context.
tiltfive::Error::kGfxContextInitFail
@ kGfxContextInitFail
Failed to initialize graphics context.
tiltfive::Error::kDecodeError
@ kDecodeError
Failed to decode.
tiltfive::Error::kDeviceLost
@ kDeviceLost
Device lost.
tiltfive::Error::kInvalidGfxContext
@ kInvalidGfxContext
Graphics context is invalid.
tiltfive::Error::kTimeout
@ kTimeout
Timeout.
tiltfive::Error::kInvalidArgument
@ kInvalidArgument
Argument(s) are invalid.
tiltfive::Error::kUnsupported
@ kUnsupported
Action is unsupported.
tiltfive::Error::kUnavailable
@ kUnavailable
Target is unavailable.
tiltfive::Error::kSuccess
@ kSuccess
Success.
tiltfive::Error::kIoFailure
@ kIoFailure
Misc IO failure.
tiltfive::Error::kMiscRemote
@ kMiscRemote
Miscellaneous remote error.
tiltfive::Error::kInvalidState
@ kInvalidState
Incorrect state for the request.
tiltfive::Error::kNoService
@ kNoService
Service isn't connected.
tiltfive::Error::kOverflow
@ kOverflow
Buffer overflow.
tiltfive::Error::kInvalidBuffer
@ kInvalidBuffer
Invalid buffer size.
tiltfive::Error::kPermissionDenied
@ kPermissionDenied
Permission denied.
tiltfive::Error::kTargetNotFound
@ kTargetNotFound
Target (wand) not found.
tiltfive::Error::kInternalError
@ kInternalError
An internal error occurred.
system_error
make_error_code
error_code make_error_code(future_errc __errc) noexcept
std::is_error_code_enum
std::error_code
std::integral_constant
tiltfive::details::ErrorCategory
Definition: errors.hpp:136
basic_string< char >