Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
DelegateResponseError Class Referenceabstract

Delegate Response Error. More...

#include <src/api/mip/error.h>

+ Inheritance diagram for DelegateResponseError:
+ Collaboration diagram for DelegateResponseError:

Public Member Functions

void AddDebugInfo (const std::string &key, const std::string &value, bool sensitive=false)
 Add debug info entry.
 
virtual std::shared_ptr< ErrorClone () const =0
 Clone the error.
 
 DelegateResponseError (const std::exception_ptr &except)
 Creates an error/exception object.
 
 DelegateResponseError (const std::string &message)
 Creates an error/exception object.
 
 DelegateResponseError (const std::string &message, const std::string &stackTrace, const std::string &name="DelegateResponseError")
 Creates an error/exception object.
 
 DelegateResponseError (const std::string &message, long HResult)
 Creates an error/exception object.
 
 DelegateResponseError (const std::string &message, long HResult, const std::string &stackTrace, const std::string &name="DelegateResponseError")
 Creates an error/exception object.
 
const std::map< std::string, std::string > & GetDebugInfo () const
 Get debug info.
 
const std::string & GetErrorName () const
 Get the error name.
 
virtual ErrorType GetErrorType () const
 Get the error type.
 
const std::string & GetMessage (bool maskPII=false) const
 Get the error message.
 
void SetMessage (const std::string &msg)
 Set the error message.
 
char const * what () const noexcept override
 Get the error message.
 

Public Attributes

std::map< std::string, std::string > mDebugInfo
 
std::string mMessage
 
std::string mName
 
ErrorType mType
 

Detailed Description

Delegate Response Error.

Thrown or returned in response to encountering an error in a delegate method.

Definition at line 315 of file error.h.

Constructor & Destructor Documentation

◆ DelegateResponseError() [1/5]

DelegateResponseError::DelegateResponseError ( const std::exception_ptr & except)
inlineexplicit

Creates an error/exception object.

Call this method from a MIP delegate function to create a MIP or standard C++ exception object.

Parameters
exceptThe C++ exception that was encountered.

Definition at line 323 of file error.h.

323 :
324 Error(std::string(), std::string("DelegateResponseError"), ErrorType::DELEGATE_RESPONSE),
325 mCurrentException(except) {
326 if (except) {
327 try {
328 std::rethrow_exception(except);
329 } catch(const Error& error) {
330 *static_cast<Error*>(this) = error;
331 } catch (const std::exception& thisException) {
332 this->mMessage = std::string(thisException.what());
333 }
334 }
335 }
Base class for all errors that will be reported (thrown or returned) from MIP SDK.
Definition error.h:114
std::string mMessage
Definition error.h:224
@ DELEGATE_RESPONSE
Error generated from delegated response.

References Error::mMessage.

◆ DelegateResponseError() [2/5]

DelegateResponseError::DelegateResponseError ( const std::string & message,
const std::string & stackTrace,
const std::string & name = "DelegateResponseError" )
inline

Creates an error/exception object.

Call this method from a MIP delegate function to create a generic MIP C++ exception object.

Parameters
messageMessage associated with the exception.
stackTraceThe stack trace at the time of the exception.
nameSome string to uniquely identify the type of this exception.

Definition at line 345 of file error.h.

349 : Error(message, name, ErrorType::DELEGATE_RESPONSE) {
350 AddDebugInfo(GetStackTraceString(), stackTrace);
351 }
void AddDebugInfo(const std::string &key, const std::string &value, bool sensitive=false)
Add debug info entry.
Definition error.h:179
constexpr const char * GetStackTraceString()
Definition error.h:50

References Error::AddDebugInfo(), and anonymous_namespace{error.h}::GetStackTraceString().

◆ DelegateResponseError() [3/5]

DelegateResponseError::DelegateResponseError ( const std::string & message,
long HResult,
const std::string & stackTrace,
const std::string & name = "DelegateResponseError" )
inline

Creates an error/exception object.

Call this method from a MIP delegate function to create a generic MIP C++ exception object.

Parameters
messageMessage associated with the exception.
HResultHResult that identifies the error that caused this exception.
stackTraceThe stack trace at the time of the exception.
nameSome string to uniquely identify the type of this exception.

Definition at line 362 of file error.h.

367 : Error(message, name, ErrorType::DELEGATE_RESPONSE) {
368 std::stringstream hrStream;
369 hrStream << std::hex << HResult;
370 AddDebugInfo(GetHResultString(), hrStream.str());
371 AddDebugInfo(GetStackTraceString(), stackTrace);
372 }
constexpr const char * GetHResultString()
Definition error.h:54

References Error::AddDebugInfo(), anonymous_namespace{error.h}::GetHResultString(), and anonymous_namespace{error.h}::GetStackTraceString().

◆ DelegateResponseError() [4/5]

DelegateResponseError::DelegateResponseError ( const std::string & message,
long HResult )
inline

Creates an error/exception object.

Call this method from a MIP delegate function to create a generic MIP C++ exception object.

Parameters
messageMessage associated with the exception.
HResultHResult that identifies the error that caused this exception.

Definition at line 381 of file error.h.

382 : Error(message, std::string("DelegateResponseError"), ErrorType::DELEGATE_RESPONSE) {
383 std::stringstream hrStream;
384 hrStream << std::hex << HResult;
385 AddDebugInfo(GetHResultString(), hrStream.str());
386 }

References Error::AddDebugInfo(), and anonymous_namespace{error.h}::GetHResultString().

◆ DelegateResponseError() [5/5]

DelegateResponseError::DelegateResponseError ( const std::string & message)
inline

Creates an error/exception object.

Call this method from a MIP delegate function to create a generic MIP C++ exception object.

Parameters
messageMessage associated with the exception.

Definition at line 394 of file error.h.

395 : Error(message, std::string("DelegateResponseError"), ErrorType::DELEGATE_RESPONSE) {
396 }

Member Function Documentation

◆ AddDebugInfo()

void Error::AddDebugInfo ( const std::string & key,
const std::string & value,
bool sensitive = false )
inlineinherited

Add debug info entry.

Parameters
keyDebug info key
valueDebug info value

Definition at line 179 of file error.h.

179 {
180 if (!key.empty() && !value.empty()) {
181 mDebugInfo[key] = value;
182 mFormattedMessage = mFormattedMessage + ", " + key + "=" + value;
183 mMaskedMessage = mMaskedMessage + ", " + key + "=" + (sensitive ? "***" : value);
184 }
185 }
std::map< std::string, std::string > mDebugInfo
Definition error.h:225

References Error::mDebugInfo.

Referenced by DelegateResponseError(), DelegateResponseError(), and DelegateResponseError().

◆ Clone()

virtual std::shared_ptr< Error > Error::Clone ( ) const
pure virtualinherited

Clone the error.

Returns
a clone of the error.

Implemented in JustificationRequiredError.

◆ GetDebugInfo()

const std::map< std::string, std::string > & Error::GetDebugInfo ( ) const
inlineinherited

Get debug info.

Returns
Debug info (keys/values)

Definition at line 192 of file error.h.

192{ return mDebugInfo; }

References Error::mDebugInfo.

◆ GetErrorName()

const std::string & Error::GetErrorName ( ) const
inlineinherited

Get the error name.

Returns
the error name.

Definition at line 144 of file error.h.

144{ return mName; }
std::string mName
Definition error.h:226

References Error::mName.

◆ GetErrorType()

virtual ErrorType Error::GetErrorType ( ) const
inlinevirtualinherited

Get the error type.

Returns
the error type.

Definition at line 137 of file error.h.

137{ return mType; }
ErrorType mType
Definition error.h:227

References Error::mType.

◆ GetMessage()

const std::string & Error::GetMessage ( bool maskPII = false) const
inlineinherited

Get the error message.

Returns
the error message.

Definition at line 151 of file error.h.

151 {
152 return maskPII ? mMaskedMessage : mFormattedMessage;
153 }

◆ SetMessage()

void Error::SetMessage ( const std::string & msg)
inlineinherited

Set the error message.

Parameters
msgthe error message.

Definition at line 160 of file error.h.

160 {
161 std::string* targetStrings[] = { &mFormattedMessage, &mMaskedMessage };
162 for (auto* targetString : targetStrings) {
163 size_t pos = targetString->find(mMessage);
164 if (pos != std::string::npos) {
165 targetString->replace(pos, mMessage.length(), msg);
166 } else {
167 targetString->replace(0, 0, msg);
168 }
169 }
170 mMessage = msg;
171 }

References Error::mMessage.

◆ what()

char const * Error::what ( ) const
inlineoverridenoexceptinherited

Get the error message.

Returns
the error message

Definition at line 121 of file error.h.

121 {
122 return mFormattedMessage.c_str();
123 }

Member Data Documentation

◆ mDebugInfo

std::map<std::string, std::string> Error::mDebugInfo
inherited

Definition at line 225 of file error.h.

Referenced by Error::AddDebugInfo(), and Error::GetDebugInfo().

◆ mMessage

std::string Error::mMessage
inherited

Definition at line 224 of file error.h.

Referenced by DelegateResponseError(), and Error::SetMessage().

◆ mName

std::string Error::mName
inherited

Definition at line 226 of file error.h.

Referenced by Error::GetErrorName().

◆ mType

ErrorType Error::mType
inherited

Definition at line 227 of file error.h.

Referenced by Error::GetErrorType().


The documentation for this class was generated from the following file: