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

Base class for all errors that will be reported (thrown or returned) from MIP SDK. More...

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

Inheritance diagram for Error:
Collaboration diagram for Error:

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.
 
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

Base class for all errors that will be reported (thrown or returned) from MIP SDK.

Definition at line 116 of file error.h.

Member Function Documentation

◆ AddDebugInfo()

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

Add debug info entry.

Parameters
keyDebug info key
valueDebug info value

Definition at line 181 of file error.h.

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

References mDebugInfo.

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

◆ Clone()

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

Clone the error.

Returns
a clone of the error.

Implemented in JustificationRequiredError.

◆ GetDebugInfo()

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

Get debug info.

Returns
Debug info (keys/values)

Definition at line 194 of file error.h.

194{ return mDebugInfo; }

References mDebugInfo.

◆ GetErrorName()

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

Get the error name.

Returns
the error name.

Definition at line 146 of file error.h.

146{ return mName; }
std::string mName
Definition error.h:228

References mName.

◆ GetErrorType()

virtual ErrorType Error::GetErrorType ( ) const
inlinevirtual

Get the error type.

Returns
the error type.

Definition at line 139 of file error.h.

139{ return mType; }
ErrorType mType
Definition error.h:229

References mType.

◆ GetMessage()

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

Get the error message.

Returns
the error message.

Definition at line 153 of file error.h.

153 {
154 return maskPII ? mMaskedMessage : mFormattedMessage;
155 }

◆ SetMessage()

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

Set the error message.

Parameters
msgthe error message.

Definition at line 162 of file error.h.

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

References mMessage.

◆ what()

char const * Error::what ( ) const
inlineoverridenoexcept

Get the error message.

Returns
the error message

Definition at line 123 of file error.h.

123 {
124 return mFormattedMessage.c_str();
125 }

Member Data Documentation

◆ mDebugInfo

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

Definition at line 227 of file error.h.

Referenced by AddDebugInfo(), and GetDebugInfo().

◆ mMessage

std::string Error::mMessage

Definition at line 226 of file error.h.

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

◆ mName

std::string Error::mName

Definition at line 228 of file error.h.

Referenced by GetErrorName().

◆ mType

ErrorType Error::mType

Definition at line 229 of file error.h.

Referenced by GetErrorType().


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