OrbbecSDK
2.8.7
OrbbecSDK: Software-Development-Kit for Orbbec 3D Cameras
Toggle main menu visibility
Loading...
Searching...
No Matches
include
libobsensor
hpp
Error.hpp
Go to the documentation of this file.
1
// Copyright (c) Orbbec Inc. All Rights Reserved.
2
// Licensed under the MIT License.
3
9
#pragma once
10
11
#include "
Types.hpp
"
12
#include "
libobsensor/h/Error.h
"
13
#include <memory>
14
15
namespace
ob
{
16
class
Error :
public
std::exception {
17
private
:
18
ob_error
*impl_;
19
27
explicit
Error(
ob_error
*error) : impl_(error) {};
28
29
Error &operator=(
const
Error &) =
default
;
30
31
public
:
38
static
void
handle
(
ob_error
**error,
bool
throw_exception =
true
) {
39
if
(!error || !*error) {
// no error
40
return
;
41
}
42
43
if
(throw_exception) {
44
throw
Error(*error);
45
}
46
else
{
47
ob_delete_error
(*error);
48
*error =
nullptr
;
49
}
50
}
51
55
~Error
()
override
{
56
if
(impl_) {
57
ob_delete_error
(impl_);
58
impl_ =
nullptr
;
59
}
60
}
61
67
const
char
*
what
() const noexcept
override
{
68
return
impl_->message;
69
}
70
77
OBExceptionType
getExceptionType
() const noexcept {
78
return
impl_->exception_type;
79
}
80
86
const
char
*
getFunction
() const noexcept {
87
return
impl_->function;
88
}
89
95
const
char
*
getArgs
() const noexcept {
96
return
impl_->args;
97
}
98
105
const
char
*
getMessage
() const noexcept {
106
return
impl_->message;
107
}
108
114
OBStatus
getStatus
() const noexcept {
115
return
impl_->status;
116
}
117
118
public
:
119
// The following interfaces are deprecated and are retained here for compatibility purposes.
120
const
char
*
getName
() const noexcept {
121
return
impl_->function;
122
}
123
};
124
}
// namespace ob
Error.h
Functions for handling errors, mainly used for obtaining error messages.
ob_delete_error
OB_EXPORT void ob_delete_error(ob_error *error)
Delete the error object.
OBStatus
OBStatus
error code
Definition
ObTypes.h:76
OBExceptionType
OBExceptionType
The exception types in the SDK, through the exception type, you can easily determine the specific typ...
Definition
ObTypes.h:136
Types.hpp
ob::Error::getName
const char * getName() const noexcept
Definition
Error.hpp:120
ob::Error::what
const char * what() const noexcept override
Returns the error message of the exception.
Definition
Error.hpp:67
ob::Error::getMessage
const char * getMessage() const noexcept
Returns the error message of the exception.
Definition
Error.hpp:105
ob::Error::~Error
~Error() override
Destroy the Error object.
Definition
Error.hpp:55
ob::Error::getFunction
const char * getFunction() const noexcept
Returns the name of the function where the exception occurred.
Definition
Error.hpp:86
ob::Error::getArgs
const char * getArgs() const noexcept
Returns the arguments of the function where the exception occurred.
Definition
Error.hpp:95
ob::Error::getStatus
OBStatus getStatus() const noexcept
Returns the error status code of the exception.
Definition
Error.hpp:114
ob::Error::getExceptionType
OBExceptionType getExceptionType() const noexcept
Returns the exception type of the exception.
Definition
Error.hpp:77
ob::Error::handle
static void handle(ob_error **error, bool throw_exception=true)
A static function to handle the ob_error and throw an exception if needed.
Definition
Error.hpp:38
ob
Definition
Context.hpp:22
ob_error
The error class exposed by the SDK, users can get detailed error information according to the error.
Definition
ObTypes.h:159
Generated on
for OrbbecSDK by
1.17.0