Microsoft Information Protection (MIP) SDK for C++: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C++
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27/**
28 * @brief A file containing the MIP SDK error types.
29 *
30 * @file error.h
31 */
32
33#ifndef API_MIP_ERROR_H_
34#define API_MIP_ERROR_H_
35
36#include <algorithm>
37#include <exception>
38#include <map>
39#include <memory>
40#include <sstream>
41#include <stdexcept>
42#include <string>
43#include <vector>
44
45#include "mip/common_types.h"
46#include "mip/mip_namespace.h"
47
48namespace {
49
50constexpr const char* GetStackTraceString() {
51 return "StackTrace";
52}
53
54constexpr const char* GetHResultString() {
55 return "HResult";
56}
57
58constexpr const char* GetBadInputErrorString() {
59 return "BadInputError";
60}
61
62constexpr const char* GetNoPermissionsExtendedErrorName() { return "NoPermissionsExtendedError"; }
63
64constexpr const char* GetErrorInfoCodesKey() { return "ExtendedErrorInfo_Codes"; }
65
66constexpr const char* GetErrorInfoMessagesKey() { return "ExtendedErrorInfo_Messages"; }
67
68constexpr const char* GetErrorInfoDetailsKey() { return "ExtendedErrorInfo_Details"; }
69
70} // namespace
71
72MIP_NAMESPACE_BEGIN
73
74enum class ErrorType : unsigned int {
75 BAD_INPUT_ERROR, /**< Caller passed bad input. */
76 INSUFFICIENT_BUFFER_ERROR, /**< Caller passed a buffer that was too small. */
77 FILE_IO_ERROR, /**< General File IO error. */
78 NETWORK_ERROR, /**< General network issues; for example, unreachable service. */
79 INTERNAL_ERROR, /**< Internal unexpected errors. */
80 JUSTIFICATION_REQUIRED, /**< Justification should be provided to complete the action on the file. */
81 NOT_SUPPORTED_OPERATION, /**< The requested operation is not yet supported. */
82 PRIVILEGED_REQUIRED, /**< Can't override privileged label when new label method is standard. */
83 ACCESS_DENIED, /**< The user could not get access to services. */
84 CONSENT_DENIED, /**< An operation that required consent from user was not granted consent. */
85 NO_PERMISSIONS, /**< The user could not get access to the content. For example, no permissions, content revoked */
86 NO_AUTH_TOKEN, /**< The user could not get access to the content due to an empty auth token. */
87 DISABLED_SERVICE, /**< The user could not get access to the content due to the service being disabled */
88 PROXY_AUTH_ERROR, /**< Proxy authentication failed. */
89 NO_POLICY, /**< No policy is configured for user/tenant */
90 OPERATION_CANCELLED, /**< Operation cancelled */
91 ADHOC_PROTECTION_REQUIRED, /**< Adhoc protection should be set to complete the action on the file*/
92 DEPRECATED_API, /**< Caller invoked a deprecated API */
93 TEMPLATE_NOT_FOUND, /**< Template ID is not recognized */
94 LABEL_NOT_FOUND, /**< Label ID is not recognized */
95 LABEL_DISABLED, /**< Label is disabled or inactive */
96 DOUBLE_KEY_DISABLED, /**< The double key feature has not been enabled */
97 LICENSE_NOT_REGISTERED, /**< License not registered for tracking and revocation */
98 CONTENT_FORMAT_NOT_SUPPORTED, /**< Content format is not supported */
99 TEMPLATE_ARCHIVED, /**< Template has been archived and is unavailable for protection */
100 CUSTOMER_KEY_UNAVAILABLE, /**< Customer key not available when attempting to fetch for Bring Your Own Key Protection */
101 DELEGATE_RESPONSE, /**<Error generated from delegated response */
102 COUNT, /**<Last element in this enum. Used to keep track of the number of mip::ErrorTypes */
103};
104
106 std::string code;
107 std::string message;
108 std::map<std::string, std::string> details;
109};
110
111/**
112 * @brief Base class for all errors that will be reported (thrown or returned) from MIP SDK.
113 */
114class Error : public std::exception {
115public:
116 /**
117 * @brief Get the error message.
118 *
119 * @return the error message
120 */
121 char const* what() const noexcept override {
122 return mFormattedMessage.c_str();
123 }
124
125 /**
126 * @brief Clone the error
127 *
128 * @return a clone of the error.
129 */
130 virtual std::shared_ptr<Error> Clone() const = 0;
131
132 /**
133 * @brief Get the error type.
134 *
135 * @return the error type.
136 */
137 virtual ErrorType GetErrorType() const { return mType; }
138
139 /**
140 * @brief Get the error name.
141 *
142 * @return the error name.
143 */
144 const std::string& GetErrorName() const { return mName; }
145
146 /**
147 * @brief Get the error message.
148 *
149 * @return the error message.
150 */
151 const std::string& GetMessage(bool maskPII = false) const {
152 return maskPII ? mMaskedMessage : mFormattedMessage;
153 }
154
155 /**
156 * @brief Set the error message.
157 *
158 * @param msg the error message.
159 */
160 void SetMessage(const std::string& msg) {
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 }
172
173 /**
174 * @brief Add debug info entry
175 *
176 * @param key Debug info key
177 * @param value Debug info value
178 */
179 void AddDebugInfo(const std::string& key, const std::string& value, bool sensitive = false) {
180 if (!key.empty() && !value.empty()) {
181 mDebugInfo[key] = value;
182 mFormattedMessage = mFormattedMessage + ", " + key + "=" + value;
183 mMaskedMessage = mMaskedMessage + ", " + key + "=" + (sensitive ? "***" : value);
184 }
185 }
186
187 /**
188 * @brief Get debug info
189 *
190 * @return Debug info (keys/values)
191 */
192 const std::map<std::string, std::string>& GetDebugInfo() const { return mDebugInfo; }
193
194 /** @cond DOXYGEN_HIDE */
195 virtual ~Error() {}
196
197protected:
198 explicit Error(
199 const std::string& message,
200 const std::string& name,
201 ErrorType type)
202 : mMessage(message), mName(name), mType(type) {
203 mFormattedMessage = CreateFormattedMessage(message);
204 mMaskedMessage = mFormattedMessage;
205 }
206 explicit Error(
207 const std::string& message,
208 const std::map<std::string, std::string> debugInfo,
209 const std::map<std::string, std::string> sensitiveDebugInfo,
210 const std::string& name,
211 ErrorType type)
212 : mMessage(message), mName(name), mType(type) {
213 mFormattedMessage = CreateFormattedMessage(message);
214 mMaskedMessage = mFormattedMessage;
215 for (const auto& entry: sensitiveDebugInfo) {
216 AddDebugInfo(entry.first, entry.second, true);
217 }
218 for (const auto& entry: debugInfo) {
219 AddDebugInfo(entry.first, entry.second);
220 }
221 }
222 /** @endcond */
223
224 std::string mMessage;
225 std::map<std::string, std::string> mDebugInfo;
226 std::string mName;
228
229private:
230 std::string CreateFormattedMessage(const std::string& message) const {
231 auto formattedMessage = message;
232
233 // Remove stray newlines
234 auto isNewlineFn = [](char c) { return c == '\n' || c == '\r'; };
235 formattedMessage.erase(std::remove_if(formattedMessage.begin(), formattedMessage.end(), isNewlineFn), formattedMessage.end());
236
237 return formattedMessage;
238 }
239
240 std::string mFormattedMessage;
241 std::string mMaskedMessage;
242};
243
244/**
245 * @brief Bad input error, thrown when the input to an SDK API is invalid.
246 */
247class BadInputError : public Error {
248public:
249
250 /**
251 * @brief ErrorCode of bad input error
252 */
253 enum class ErrorCode {
254 General = 0, /**< General bad input error */
255 FileIsTooLargeForProtection = 1, /**< File is too large for protection */
256 ParameterParsing = 2, /**< Parameter cannot be parsed correctly */
257 LicenseNotTrusted = 3, /**< Publishing license not issued by trusted source */
258 DoubleKey = 4, /**< A paremeter for double key encryption is needed and missing */
259 FileFormatNotSupported = 5, /**<The input file's format is not supported */
260 };
261
262 /** @cond DOXYGEN_HIDE */
263 explicit BadInputError(
264 const std::string& message,
265 const std::string& name = GetBadInputErrorString(),
266 ErrorCode errorCode = ErrorCode::General)
267 : BadInputError(message, {{}}, {{}}, name, errorCode) {}
268
269 explicit BadInputError(
270 const std::string& message,
271 ErrorCode errorCode,
272 const std::string& name = GetBadInputErrorString())
273 : BadInputError(message, {{}}, {{}}, name, errorCode) {}
274
275 explicit BadInputError(
276 const std::string& message,
277 const std::map<std::string, std::string>& debugInfo,
278 const std::map<std::string, std::string> sensitiveDebugInfo,
279 const std::string& name = GetBadInputErrorString(),
280 ErrorCode errorCode = ErrorCode::General)
281 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::BAD_INPUT_ERROR),
282 mErrorCode(errorCode) {
283 AddDebugInfo("BadInputError.Code", GetErrorCodeString(errorCode));
284 }
285 std::shared_ptr<Error> Clone() const override { return std::make_shared<BadInputError>(*this); }
286 /** @endcond */
287
288 /**
289 * @brief Gets the errorCode of bad input
290 *
291 * @return ErrorCode of bad input error
292 */
293 ErrorCode GetErrorCode() const { return mErrorCode; }
294
295private:
296 ErrorCode mErrorCode;
297
298 const std::string& GetErrorCodeString(ErrorCode code) const {
299 static const std::string kUnrecognized = "UNRECOGNIZED";
300 static const std::map<ErrorCode, std::string> kCodes = {
301 { ErrorCode::General, "General" },
302 { ErrorCode::FileIsTooLargeForProtection, "FileIsTooLargeForProtection" },
303 { ErrorCode::ParameterParsing, "ParameterParsing" },
304 { ErrorCode::LicenseNotTrusted, "LicenseNotTrusted" },
305 { ErrorCode::DoubleKey, "DoubleKey" },
306 { ErrorCode::FileFormatNotSupported, "FileFormatNotSupported"},
307 };
308 return kCodes.count(code) ? kCodes.at(code) : kUnrecognized;
309 }
310};
311
312/**
313 * @brief Delegate Response Error. Thrown or returned in response to encountering an error in a delegate method.
314 */
316public:
317 /**
318 * @brief Creates an error/exception object. Call this method from a MIP delegate function to create a MIP or
319 * standard C++ exception object.
320 *
321 * @param except The C++ exception that was encountered.
322 */
323 explicit DelegateResponseError(const std::exception_ptr& except) :
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 }
336
337 /**
338 * @brief Creates an error/exception object. Call this method from a MIP delegate function to create a generic
339 * MIP C++ exception object.
340 *
341 * @param message Message associated with the exception.
342 * @param stackTrace The stack trace at the time of the exception.
343 * @param name Some string to uniquely identify the type of this exception.
344 */
346 const std::string& message,
347 const std::string& stackTrace,
348 const std::string& name = "DelegateResponseError")
349 : Error(message, name, ErrorType::DELEGATE_RESPONSE) {
350 AddDebugInfo(GetStackTraceString(), stackTrace);
351 }
352
353 /**
354 * @brief Creates an error/exception object. Call this method from a MIP delegate function to create a generic
355 * MIP C++ exception object.
356 *
357 * @param message Message associated with the exception.
358 * @param HResult HResult that identifies the error that caused this exception.
359 * @param stackTrace The stack trace at the time of the exception.
360 * @param name Some string to uniquely identify the type of this exception.
361 */
363 const std::string& message,
364 long HResult,
365 const std::string& stackTrace,
366 const std::string& name = "DelegateResponseError")
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 }
373
374 /**
375 * @brief Creates an error/exception object. Call this method from a MIP delegate function to create a generic
376 * MIP C++ exception object.
377 *
378 * @param message Message associated with the exception.
379 * @param HResult HResult that identifies the error that caused this exception.
380 */
381 DelegateResponseError(const std::string& message, long HResult)
382 : Error(message, std::string("DelegateResponseError"), ErrorType::DELEGATE_RESPONSE) {
383 std::stringstream hrStream;
384 hrStream << std::hex << HResult;
385 AddDebugInfo(GetHResultString(), hrStream.str());
386 }
387
388 /**
389 * @brief Creates an error/exception object. Call this method from a MIP delegate function to create a generic
390 * MIP C++ exception object.
391 *
392 * @param message Message associated with the exception.
393 */
394 DelegateResponseError(const std::string& message)
395 : Error(message, std::string("DelegateResponseError"), ErrorType::DELEGATE_RESPONSE) {
396 }
397
398 /** @cond DOXYGEN_HIDE */
399 explicit DelegateResponseError(const Error& error) : Error(error) {
401 }
402
403 std::shared_ptr<Error> Clone() const override {
404 // There's nothing special about this class - a clone can simply call the copy constructor.
405 auto result = std::make_shared<mip::DelegateResponseError>(*this);
406 return std::static_pointer_cast<Error>(result);
407 }
408
409 ErrorType GetErrorType() const override { return ErrorType::DELEGATE_RESPONSE; }
410
411 const std::exception_ptr& GetExceptionPtr() const { return mCurrentException; }
412
413private:
414 std::exception_ptr mCurrentException;
415 /** @endcond */
416};
417
418/**
419 * @brief Insufficient buffer error
420 */
422public:
423 /** @cond DOXYGEN_HIDE */
425 const std::string& message,
426 const std::string& name = "InsufficientBufferError")
427 : InsufficientBufferError(message, {{}}, {{}}, name) {}
429 const std::string& message,
430 const std::map<std::string, std::string>& debugInfo,
431 const std::map<std::string, std::string> sensitiveDebugInfo,
432 const std::string& name = "InsufficientBufferError")
433 : BadInputError(message, debugInfo, sensitiveDebugInfo, name) {}
434 std::shared_ptr<Error> Clone() const override { return std::make_shared<InsufficientBufferError>(*this); }
436 /** @endcond */
437};
438
439/**
440 * @brief File IO error.
441 */
442class FileIOError : public Error {
443public:
444 /** @cond DOXYGEN_HIDE */
445 explicit FileIOError(
446 const std::string& message,
447 const std::string& name = "FileIOError")
448 : FileIOError(message, {{}}, {{}}, name) {}
449 explicit FileIOError(
450 const std::string& message,
451 const std::map<std::string, std::string>& debugInfo,
452 const std::map<std::string, std::string> sensitiveDebugInfo,
453 const std::string& name = "FileIOError")
454 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::FILE_IO_ERROR) {}
455 std::shared_ptr<Error> Clone() const override { return std::make_shared<FileIOError>(*this); }
456 /** @endcond */
457};
458
459/**
460 * @brief Networking error. Caused by unexpected behavior when making network calls to service endpoints.
461 */
462class NetworkError : public Error {
463public:
464 /**
465 * @brief Category of network error
466 */
467 enum class Category {
468 Unknown = 0, /**< Unknown network failure */
469 FailureResponseCode = 1, /**< HTTP response code indicates failure */
470 BadResponse = 2, /**< HTTP response could not be read */
471 UnexpectedResponse = 3, /**< HTTP response completed but contained unexpected data */
472 NoConnection = 4, /**< Failed to establish a connection */
473 Proxy = 5, /**< Proxy failure */
474 SSL = 6, /**< SSL failure */
475 Timeout = 7, /**< Connection timed out */
476 Offline = 8, /**< Operation requires network connectivity */
477 Throttled = 9, /**< HTTP operation failed due to server traffic throttling */
478 Cancelled = 10, /**< HTTP operation has been cancelled by the application */
479 FunctionNotImplemented = 11, /**< HTTP response code indicates called function is not implemented */
480 ServiceUnavailable = 12, /**< HTTP response code indicates service is unavailable */
481 };
482
483 /** @cond DOXYGEN_HIDE */
484 explicit NetworkError(
485 Category category,
486 const std::string& sanitizedUrl,
487 const std::string& requestId,
488 int32_t statusCode,
489 const std::string& message,
490 const std::string& name = "NetworkError")
491 : NetworkError(category, statusCode, message, {{}}, {{}}, name) {
492 if (!sanitizedUrl.empty())
493 AddDebugInfo("HttpRequest.SanitizedUrl", sanitizedUrl);
494 if (!requestId.empty())
495 AddDebugInfo("HttpRequest.Id", requestId);
496 }
497
498 explicit NetworkError(
499 Category category,
500 int32_t statusCode,
501 const std::string& message,
502 const std::map<std::string, std::string>& debugInfo,
503 const std::map<std::string, std::string> sensitiveDebugInfo,
504 const std::string& name = "NetworkError")
505 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::NETWORK_ERROR),
506 mCategory(category),
507 mResponseStatusCode(statusCode) {
508 AddDebugInfo("NetworkError.Category", GetCategoryString(category));
509 if (statusCode != 0)
510 AddDebugInfo("HttpResponse.StatusCode", std::to_string(static_cast<int>(statusCode)));
511 }
512
513 std::shared_ptr<Error> Clone() const override {
514 return std::make_shared<NetworkError>(*this);
515 }
516 /** @endcond */
517
518 /**
519 * @brief Gets the category of network failure
520 *
521 * @return Category of network failure
522 */
523 Category GetCategory() const { return mCategory; }
524
525 /**
526 * @brief Gets the HTTP response status code
527 *
528 * @return HTTP response status code, 0 if none
529 */
530 int32_t GetResponseStatusCode() const { return mResponseStatusCode; }
531
532private:
533 Category mCategory;
534 int32_t mResponseStatusCode;
535
536 const std::string& GetCategoryString(Category category) const {
537 static const std::string kUnrecognized = "UNRECOGNIZED";
538 static const std::map<Category, std::string> kCategories = {
539 { Category::Unknown, "Unknown" },
540 { Category::FailureResponseCode, "FailureResponseCode" },
541 { Category::BadResponse, "BadResponse" },
542 { Category::UnexpectedResponse, "UnexpectedResponse" },
543 { Category::NoConnection, "NoConnection" },
544 { Category::Proxy, "Proxy" },
545 { Category::SSL, "SSL" },
546 { Category::Timeout, "Timeout" },
547 { Category::Offline, "Offline" },
548 { Category::Throttled, "Throttled" },
549 { Category::ServiceUnavailable, "ServiceUnavailable" },
550 { Category::Cancelled, "Cancelled" },
551 };
552 return kCategories.count(category) ? kCategories.at(category) : kUnrecognized;
553 }
554};
555
556/**
557 * @brief Proxy authentication failure
558 */
560public:
561 /** @cond DOXYGEN_HIDE */
563 const std::string& sanitizedUrl,
564 const std::string& requestId,
565 int32_t statusCode,
566 const std::string& message,
567 const std::string& name = "ProxyAuthenticationError")
568 : NetworkError(Category::Proxy, sanitizedUrl, requestId, statusCode, message, name) {}
570 int32_t statusCode,
571 const std::string& message,
572 const std::map<std::string, std::string>& debugInfo,
573 const std::map<std::string, std::string> sensitiveDebugInfo,
574 const std::string& name = "ProxyAuthenticationError")
575 : NetworkError(Category::Proxy, statusCode, message, debugInfo, sensitiveDebugInfo, name) {}
576 std::shared_ptr<Error> Clone() const override {
577 return std::make_shared<ProxyAuthenticationError>(*this);
578 }
579 ErrorType GetErrorType() const override { return ErrorType::PROXY_AUTH_ERROR; }
580 /** @endcond */
581};
582
583/**
584 * @brief Internal error. This error is thrown when something unexpected happens during execution.
585 */
586class InternalError : public Error {
587public:
588 /** @cond DOXYGEN_HIDE */
589 explicit InternalError(
590 const std::string& message,
591 const std::string& name = "InternalError")
592 : InternalError(message, {{}}, {{}}, name) {}
593 explicit InternalError(
594 const std::string& message,
595 const std::map<std::string, std::string>& debugInfo,
596 const std::map<std::string, std::string> sensitiveDebugInfo,
597 const std::string& name = "InternalError")
598 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::INTERNAL_ERROR) {}
599 std::shared_ptr<Error> Clone() const override { return std::make_shared<InternalError>(*this); }
600 /** @endcond */
601};
602
603/**
604 * @brief The operation requested by the application is not supported by the SDK.
605 */
606class NotSupportedError : public Error {
607public:
608 /** @cond DOXYGEN_HIDE */
609 explicit NotSupportedError(
610 const std::string& message,
611 const std::string& name = "NotSupportedError")
612 : NotSupportedError(message, {{}}, {{}}, name) {}
613 explicit NotSupportedError(
614 const std::string& message,
615 const std::map<std::string, std::string>& debugInfo,
616 const std::map<std::string, std::string> sensitiveDebugInfo,
617 const std::string& name = "NotSupportedError")
618 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::NOT_SUPPORTED_OPERATION) {}
619 explicit NotSupportedError(
620 const std::string& message,
621 ErrorType errorType,
622 const std::string& name = "NotSupportedError")
623 : Error(message, name, errorType) {}
624 std::shared_ptr<Error> Clone() const override { return std::make_shared<NotSupportedError>(*this); }
625 /** @endcond */
626};
627
628/**
629 * @brief Current label was assigned as a privileged operation (The equivalent to an administrator operation),
630 * therefore it can't be overriden.
631 */
633public:
634 /** @cond DOXYGEN_HIDE */
636 const std::string& message,
637 const std::string& name = "PrivilegedRequiredError")
638 : PrivilegedRequiredError(message, {{}}, {{}}, name) {}
640 const std::string& message,
641 const std::map<std::string, std::string>& debugInfo,
642 const std::map<std::string, std::string> sensitiveDebugInfo,
643 const std::string& name = "PrivilegedRequiredError")
644 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::PRIVILEGED_REQUIRED) {}
645 std::shared_ptr<Error> Clone() const override { return std::make_shared<PrivilegedRequiredError>(*this); }
646 /** @endcond */
647};
648
649/**
650 * @brief The user could not get access to the content. For example, no permissions, content revoked.
651 */
652class AccessDeniedError : public Error {
653public:
654 /** @cond DOXYGEN_HIDE */
655 explicit AccessDeniedError(
656 const std::string& message,
657 const std::string& name = "AccessDeniedError")
658 : AccessDeniedError(message, {{}}, {{}}, name) {}
659 explicit AccessDeniedError(
660 const std::string& message,
661 const std::map<std::string, std::string>& debugInfo,
662 const std::map<std::string, std::string> sensitiveDebugInfo,
663 const std::string& name = "AccessDeniedError")
664 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::ACCESS_DENIED) {}
665 virtual std::shared_ptr<Error> Clone() const override { return std::make_shared<AccessDeniedError>(*this); }
666 /** @endcond */
667};
668
669/**
670 * @brief The user could not get access to the content. For example, no permissions, content revoked.
671 */
673public:
674 /**
675 * @brief Category of no permissions error
676 */
677 enum class Category {
678 Unknown = 0, /**< Unknown no permissions failure */
679 UserNotFound = 1, /**< Requested user was not found failure */
680 AccessDenied = 2, /**< Access to content or action was not permitted */
681 AccessExpired = 3, /**< Access to content or action has expired */
682 InvalidEmail = 4,
683 UnknownTenant = 5,
684 NotOwner = 6, /**< User needs to be owner to perform action */
685 NotPremiumLicenseUser = 7, /**< User needs to be a premium license holder to perform action. Tracking and Revocation for example */
686 ClientVersionNotSupported = 8, /**< User needs to update their client in order to support features used within this document >*/
687 };
688
689 /** @cond DOXYGEN_HIDE */
690 explicit NoPermissionsError(
691 Category category,
692 const std::string& message,
693 const std::string& referrer = "",
694 const std::string& owner = "",
695 const std::string& name = "NoPermissionsError")
696 : NoPermissionsError(category, message, referrer, owner, {{}}, {{}}, name) {}
697 explicit NoPermissionsError(
698 Category category,
699 const std::string& message,
700 const std::string& referrer,
701 const std::string& owner,
702 const std::map<std::string, std::string>& debugInfo,
703 const std::map<std::string, std::string> sensitiveDebugInfo,
704 const std::string& name = "NoPermissionsError")
705 : AccessDeniedError(message, debugInfo, sensitiveDebugInfo, name), mCategory(category), mReferrer(referrer), mOwner(owner) {
706 AddDebugInfo("NoPermissionsError.Category", GetCategoryString(mCategory));
707 if (!referrer.empty())
708 AddDebugInfo("NoPermissionsError.Referrer", referrer, true);
709 if (!owner.empty())
710 AddDebugInfo("NoPermissionsError.Owner", owner, true);
711 }
712#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
713 [[deprecated]]
714#endif
715 explicit NoPermissionsError(
716 const std::string& message,
717 const std::string& referrer,
718 const std::string& owner,
719 const std::string& name = "NoPermissionsError")
720 : NoPermissionsError(Category::Unknown, message, referrer, owner, {{}}, {{}}, name) {}
721#if !defined(SWIG) && !defined(SWIG_DIRECTORS)
722 [[deprecated]]
723#endif
724 explicit NoPermissionsError(
725 const std::string& message,
726 const std::string& referrer,
727 const std::string& owner,
728 const std::map<std::string, std::string>& debugInfo,
729 const std::map<std::string, std::string> sensitiveDebugInfo,
730 const std::string& name = "NoPermissionsError")
731 : NoPermissionsError(Category::Unknown, message, referrer, owner, debugInfo, sensitiveDebugInfo, name) {}
732 std::shared_ptr<Error> Clone() const override { return std::make_shared<NoPermissionsError>(*this); }
733 ErrorType GetErrorType() const override { return ErrorType::NO_PERMISSIONS; }
734 /** @endcond */
735
736 /**
737 * @brief Gets the contact in case of missing rights to the document.
738 *
739 * @return The contact in case of missing rights to the document.
740 */
741 std::string GetReferrer() const { return mReferrer; }
742
743 /**
744 * @brief Gets the owner of the document
745 *
746 * @return Document owner
747 */
748 std::string GetOwner() const { return mOwner; }
749
750 /**
751 * @brief Gets the category of no permissions failure
752 *
753 * @return Category of no permissions failure
754 */
755 Category GetCategory() const { return mCategory; }
756
757private:
758 Category mCategory;
759 std::string mReferrer;
760 std::string mOwner;
761
762 const std::string& GetCategoryString(Category category) const {
763 static const std::string kUnrecognized = "UNRECOGNIZED";
764 static const std::map<Category, std::string> kCategories = {
765 { Category::Unknown, "Unknown" },
766 { Category::UserNotFound, "UserNotFound" },
767 { Category::AccessDenied, "AccessDenied" },
768 { Category::AccessExpired, "AccessExpired" },
769 { Category::InvalidEmail, "InvalidEmail" },
770 { Category::UnknownTenant, "UnknownTenant" },
771 { Category::NotOwner, "NotOwner" },
772 { Category::NotPremiumLicenseUser, "NotPremiumLicenseUser" },
773 { Category::ClientVersionNotSupported, "ClientVersionNotSupported" }
774 };
775 return kCategories.count(category) ? kCategories.at(category) : kUnrecognized;
776 }
777};
778
779/**
780 * @brief The user could not get access to the content due to extended Access checks like ABAC.
781 */
783public:
784 /** @cond DOXYGEN_HIDE */
785 explicit NoPermissionsExtendedError(Category category,
786 const std::string& message,
787 const std::string& referrer,
788 const std::string& owner,
789 const std::vector<ExtendedErrorInfo>& extendedErrorInfo,
790 const std::string& name = GetNoPermissionsExtendedErrorName())
791 : NoPermissionsError(category, message, referrer, owner, name),
792 mExtendedErrorInfo(extendedErrorInfo) { AddExtendedErrorInfoToDebugInfo(extendedErrorInfo); }
793
794 explicit NoPermissionsExtendedError(Category category,
795 const std::string& message,
796 const std::string& referrer,
797 const std::string& owner,
798 const std::map<std::string, std::string> debugInfo,
799 const std::map<std::string, std::string> sensitiveDebugInfo,
800 const std::vector<ExtendedErrorInfo>& extendedErrorInfo,
801 const std::string& name = GetNoPermissionsExtendedErrorName())
802 : NoPermissionsError(category, message, referrer, owner, debugInfo, sensitiveDebugInfo, name),
803 mExtendedErrorInfo(extendedErrorInfo) { AddExtendedErrorInfoToDebugInfo(extendedErrorInfo); }
804
805 std::shared_ptr<Error> Clone() const override { return std::make_shared<NoPermissionsExtendedError>(*this); }
806
807 std::vector<ExtendedErrorInfo> GetExtendedErrorInfo() const {
808 return mExtendedErrorInfo;
809 }
810 /** @endcond */
811
812private:
813 void AddExtendedErrorInfoToDebugInfo(const std::vector<ExtendedErrorInfo>& extendedErrorInfo) {
814 std::stringstream codesStream;
815 std::stringstream messagesStream;
816 std::stringstream detailsStream;
817
818 static const std::string seperator = ",";
819 static const std::string objSeperator = ";";
820 static const std::string mapElementSeperator = "|";
821 for (size_t i = 0; i < extendedErrorInfo.size(); i++) {
822 codesStream << extendedErrorInfo[i].code;
823 messagesStream << extendedErrorInfo[i].message;
824 std::map<std::string, std::string>::const_iterator detailsIter = extendedErrorInfo[i].details.begin();
825 while (detailsIter != extendedErrorInfo[i].details.end()) {
826 detailsStream << detailsIter->first << seperator << detailsIter->second;
827 detailsIter++;
828 if (detailsIter != extendedErrorInfo[i].details.end()) {
829 detailsStream << mapElementSeperator;
830 }
831 }
832
833 if (i + 1 < extendedErrorInfo.size()) {
834 codesStream << objSeperator;
835 messagesStream << objSeperator;
836 detailsStream << objSeperator;
837 }
838 }
839
840 if (!extendedErrorInfo.empty()) {
841 AddDebugInfo(GetErrorInfoCodesKey(), codesStream.str());
842 AddDebugInfo(GetErrorInfoMessagesKey(), messagesStream.str());
843 AddDebugInfo(GetErrorInfoDetailsKey(), detailsStream.str());
844 }
845 }
846
847 std::vector<ExtendedErrorInfo> mExtendedErrorInfo;
848};
849
850/**
851 * @brief The user could not get access to the content due to missing authentication token
852 */
854public:
855 /** @cond DOXYGEN_HIDE */
856 explicit NoAuthTokenError(
857 const std::string& message,
858 const std::string& name = "NoAuthTokenError")
859 : NoAuthTokenError(message, {{}}, {{}}, name) {}
860 explicit NoAuthTokenError(
861 const std::string& message,
862 const std::map<std::string, std::string>& debugInfo,
863 const std::map<std::string, std::string> sensitiveDebugInfo,
864 const std::string& name = "NoAuthTokenError")
865 : AccessDeniedError(message, debugInfo, sensitiveDebugInfo, name) {}
866 std::shared_ptr<Error> Clone() const override { return std::make_shared<NoAuthTokenError>(*this); }
867 ErrorType GetErrorType() const override { return ErrorType::NO_AUTH_TOKEN; }
868 /** @endcond */
869};
870
871/**
872 * @brief The user could not get access to the content due to a service being disabled
873 */
875public:
876 /**
877 * @brief Describes the extent for which the service is disabled
878 */
879 enum class Extent {
880 User, /**< Service is disabled for the user. */
881 Device, /**< Service is disabled for the device. */
882 Platform, /**< Service is disabled for the platform. */
883 Tenant, /**< Service is disabled for the tenant. */
884 };
885
886 /** @cond DOXYGEN_HIDE */
887 explicit ServiceDisabledError(
888 Extent extent,
889 const std::string& requestId,
890 const std::string& message,
891 const std::string& name = "ServiceDisabledError")
892 : ServiceDisabledError(extent, message, {{}}, {{}}, name) {
893 if (!requestId.empty())
894 AddDebugInfo("HttpRequest.Id", requestId);
895 }
896 explicit ServiceDisabledError(
897 Extent extent,
898 const std::string& message,
899 const std::map<std::string, std::string>& debugInfo,
900 const std::map<std::string, std::string> sensitiveDebugInfo,
901 const std::string& name = "ServiceDisabledError")
902 : AccessDeniedError(message, debugInfo, sensitiveDebugInfo, name),
903 mExtent(extent) {
904 AddDebugInfo("ServiceDisabledError.Extent", GetExtentString(extent));
905 }
906
907 std::shared_ptr<Error> Clone() const override { return std::make_shared<ServiceDisabledError>(*this); }
908 ErrorType GetErrorType() const override { return ErrorType::DISABLED_SERVICE; }
909 /** @endcond */
910
911 /**
912 * @brief Gets the extent for which the service is disabled
913 *
914 * @return Extent for which the service is disabled
915 */
916 Extent GetExtent() const { return mExtent; }
917
918private:
919 const std::string& GetExtentString(Extent extent) const {
920 static const std::string kUnrecognized = "UNRECOGNIZED";
921 static const std::map<Extent, std::string> kExtents = {
922 { Extent::User, "User" },
923 { Extent::Device, "Device" },
924 { Extent::Platform, "Platform" },
925 { Extent::Tenant, "Tenant" },
926 };
927 return kExtents.count(extent) ? kExtents.at(extent) : kUnrecognized;
928 }
929
930 Extent mExtent;
931};
932
933/**
934 * @brief An operation that required consent from user was not granted consent.
935 */
936class ConsentDeniedError : public Error {
937public:
938 /** @cond DOXYGEN_HIDE */
939 explicit ConsentDeniedError(
940 const std::string& message,
941 const std::string& name = "ConsentDeniedError")
942 : ConsentDeniedError(message, {{}}, {{}}, name) {}
943 explicit ConsentDeniedError(
944 const std::string& message,
945 const std::map<std::string, std::string>& debugInfo,
946 const std::map<std::string, std::string> sensitiveDebugInfo,
947 const std::string& name = "ConsentDeniedError")
948 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::CONSENT_DENIED) {}
949 std::shared_ptr<Error> Clone() const override { return std::make_shared<ConsentDeniedError>(*this); }
950 /** @endcond */
951};
952
953/**
954 * @brief Tenant policy is not configured for classification/labels.
955 */
956class NoPolicyError : public Error {
957public:
958 /** @cond DOXYGEN_HIDE */
959
960 /**
961 * @brief Describes what is the failure point while parsing.
962 */
963 enum class Category {
964 SyncFile, /**< Policy is missing syncfile node, override label node */
965 Labels, /**< Policy is missing labels node, override rules node */
966 Rules /**< Policy is missing rules node. */
967 };
968
969 explicit NoPolicyError(
970 const std::string& message,
971 const Category category,
972 const std::string& name = "NoPolicyError")
973 : NoPolicyError(message, category, {{}}, {{}}, name) {}
974 explicit NoPolicyError(
975 const std::string& message,
976 const Category category,
977 const std::map<std::string, std::string>& debugInfo,
978 const std::map<std::string, std::string> sensitiveDebugInfo,
979 const std::string& name = "NoPolicyError")
980 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::NO_POLICY),
981 mCategory(category) {
982 AddDebugInfo("NoPolicyError.Category", GetCategoryString(category));
983 }
984
985 std::shared_ptr<Error> Clone() const override { return std::make_shared<NoPolicyError>(*this); }
986 Category GetCategory() const { return mCategory; }
987private:
988 const std::string& GetCategoryString(Category category) const {
989 static const std::string kUnrecognized = "UNRECOGNIZED";
990 static const std::map<Category, std::string> kCategories = {
991 { Category::SyncFile, "SyncFile" },
992 { Category::Labels, "Labels" },
993 { Category::Rules, "Rules" },
994 };
995 return kCategories.count(category) ? kCategories.at(category) : kUnrecognized;
996 }
997
998 Category mCategory;
999 /** @endcond */
1000};
1001
1002/**
1003 * @brief Operation was cancelled.
1004 */
1006public:
1007 /** @cond DOXYGEN_HIDE */
1008 explicit OperationCancelledError(
1009 const std::string& message,
1010 const std::string& name = "OperationCancelledError")
1011 : OperationCancelledError(message, {{}}, {{}}, name) {}
1012 explicit OperationCancelledError(
1013 const std::string& message,
1014 const std::map<std::string, std::string>& debugInfo,
1015 const std::map<std::string, std::string> sensitiveDebugInfo,
1016 const std::string& name = "OperationCancelledError")
1017 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::OPERATION_CANCELLED) {}
1018 std::shared_ptr<Error> Clone() const override { return std::make_shared<OperationCancelledError>(*this); }
1019 /** @endcond */
1020};
1021
1022/**
1023 * @brief Adhoc protection should be set to complete the action on the file.
1024*/
1026public:
1027 /** @cond DOXYGEN_HIDE */
1029 const std::string& message,
1030 const std::string& name = "AdhocProtectionRequiredError")
1031 : AdhocProtectionRequiredError(message, {{}}, {{}}, name) {}
1033 const std::string& message,
1034 const std::map<std::string, std::string>& debugInfo,
1035 const std::map<std::string, std::string> sensitiveDebugInfo,
1036 const std::string& name = "AdhocProtectionRequiredError")
1037 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::ADHOC_PROTECTION_REQUIRED) {}
1038 std::shared_ptr<Error> Clone() const override { return std::make_shared<AdhocProtectionRequiredError>(*this); }
1039 /** @endcond */
1040};
1041
1042/**
1043 * @brief Caller invoked a deprecated API
1044 */
1046public:
1047 /** @cond DOXYGEN_HIDE */
1048 explicit DeprecatedApiError(
1049 const std::string& message,
1050 const std::string& name = "DeprecatedApiError")
1051 : DeprecatedApiError(message, {{}}, {{}}, name) {}
1052 explicit DeprecatedApiError(
1053 const std::string& message,
1054 const std::map<std::string, std::string>& debugInfo,
1055 const std::map<std::string, std::string> sensitiveDebugInfo,
1056 const std::string& name = "DeprecatedApiError")
1057 : Error(message, debugInfo, sensitiveDebugInfo, name, ErrorType::DEPRECATED_API) {}
1058 std::shared_ptr<Error> Clone() const override { return std::make_shared<DeprecatedApiError>(*this); }
1059 /** @endcond */
1060};
1061
1062/**
1063 * @brief Template ID is not recognized by RMS service
1064 */
1066public:
1067 /** @cond DOXYGEN_HIDE */
1068 explicit TemplateNotFoundError(
1069 const std::string& message,
1070 const std::string& name = "TemplateNotFoundError")
1071 : TemplateNotFoundError(message, {{}}, {{}}, name) {}
1072 explicit TemplateNotFoundError(
1073 const std::string& message,
1074 const std::map<std::string, std::string>& debugInfo,
1075 const std::map<std::string, std::string> sensitiveDebugInfo,
1076 const std::string& name = "TemplateNotFoundError")
1077 : BadInputError(message, debugInfo, sensitiveDebugInfo, name) {}
1078
1079 std::shared_ptr<Error> Clone() const override { return std::make_shared<TemplateNotFoundError>(*this); }
1080 ErrorType GetErrorType() const override { return ErrorType::TEMPLATE_NOT_FOUND; }
1081 /** @endcond */
1082};
1083
1084/**
1085 * @brief Template ID is archived and unavailable for protection
1086 */
1088public:
1089 /** @cond DOXYGEN_HIDE */
1090 explicit TemplateArchivedError(
1091 const std::string& message,
1092 const std::string& name = "TemplateArchivedError")
1093 : TemplateArchivedError(message, {{}}, {{}}, name) {}
1094 explicit TemplateArchivedError(
1095 const std::string& message,
1096 const std::map<std::string, std::string>& debugInfo,
1097 const std::map<std::string, std::string> sensitiveDebugInfo,
1098 const std::string& name = "TemplateArchivedError")
1099 : BadInputError(message, debugInfo, sensitiveDebugInfo, name) {}
1100
1101 std::shared_ptr<Error> Clone() const override { return std::make_shared<TemplateArchivedError>(*this); }
1102 ErrorType GetErrorType() const override { return ErrorType::TEMPLATE_ARCHIVED; }
1103 /** @endcond */
1104};
1105
1106/**
1107 * @brief Content Format is not supported
1108 */
1110public:
1111 /** @cond DOXYGEN_HIDE */
1113 const std::string& message,
1114 const std::string& name = "ContentFormatNotSupportedError")
1115 : ContentFormatNotSupportedError(message, {{}}, {{}}, name) {}
1117 const std::string& message,
1118 const std::map<std::string, std::string>& debugInfo,
1119 const std::map<std::string, std::string> sensitiveDebugInfo,
1120 const std::string& name = "ContentFormatNotSupportedError")
1121 : BadInputError(message, debugInfo, sensitiveDebugInfo, name) {}
1122
1123 std::shared_ptr<Error> Clone() const override { return std::make_shared<ContentFormatNotSupportedError>(*this); }
1125 /** @endcond */
1126};
1127
1128/**
1129 * @brief Label ID is not recognized
1130 */
1132public:
1133 /** @cond DOXYGEN_HIDE */
1134 explicit LabelNotFoundError(
1135 const std::string& message,
1136 const std::string& name = "LabelNotFoundError")
1137 : LabelNotFoundError(message, {{}}, {{}}, name) {}
1138 explicit LabelNotFoundError(
1139 const std::string& message,
1140 const std::map<std::string, std::string>& debugInfo,
1141 const std::map<std::string, std::string> sensitiveDebugInfo,
1142 const std::string& name = "LabelNotFoundError")
1143 : BadInputError(message, debugInfo, sensitiveDebugInfo, name) {}
1144
1145 std::shared_ptr<Error> Clone() const override { return std::make_shared<LabelNotFoundError>(*this); }
1146 ErrorType GetErrorType() const override { return ErrorType::LABEL_NOT_FOUND; }
1147 /** @endcond */
1148};
1149
1150/**
1151 * @brief License is not registered
1152 */
1154public:
1155 /** @cond DOXYGEN_HIDE */
1157 const std::string& message,
1158 const std::string& name = "LicenseNotRegisteredError")
1159 : LicenseNotRegisteredError(message, {{}}, {{}}, name) {}
1161 const std::string& message,
1162 const std::map<std::string, std::string>& debugInfo,
1163 const std::map<std::string, std::string> sensitiveDebugInfo,
1164 const std::string& name = "LicenseNotRegisteredError")
1165 : BadInputError(message, debugInfo, sensitiveDebugInfo, name) {}
1166
1167 std::shared_ptr<Error> Clone() const override { return std::make_shared<LicenseNotRegisteredError>(*this); }
1168 ErrorType GetErrorType() const override { return ErrorType::LICENSE_NOT_REGISTERED; }
1169 /** @endcond */
1170};
1171
1172/**
1173 * @brief Label is disabled or inactive
1174 */
1176public:
1177 /** @cond DOXYGEN_HIDE */
1178 explicit LabelDisabledError(
1179 const std::string& message,
1180 const std::string& name = "LabelDisabledError")
1181 : LabelDisabledError(message, {{}}, {{}}, name) {}
1182 explicit LabelDisabledError(
1183 const std::string& message,
1184 const std::map<std::string, std::string>& debugInfo,
1185 const std::map<std::string, std::string> sensitiveDebugInfo,
1186 const std::string& name = "LabelDisabledError")
1187 : BadInputError(message, debugInfo, sensitiveDebugInfo, name) {}
1188 std::shared_ptr<Error> Clone() const override { return std::make_shared<LabelDisabledError>(*this); }
1189 ErrorType GetErrorType() const override { return ErrorType::LABEL_DISABLED; }
1190 /** @endcond */
1191};
1192
1193/**
1194 * @brief Bring your own encryption key needed and unavailable
1195 */
1197public:
1198 /** @cond DOXYGEN_HIDE */
1200 const std::string& message,
1201 const std::string& name = "CustomerKeyUnavailableError")
1202 : CustomerKeyUnavailableError(message, {{}}, {{}}, name) {}
1204 const std::string& message,
1205 const std::map<std::string, std::string>& debugInfo,
1206 const std::map<std::string, std::string>& sensitiveDebugInfo,
1207 const std::string& name = "CustomerKeyUnavailableError")
1208 : AccessDeniedError(message, debugInfo, sensitiveDebugInfo, name) {}
1209 std::shared_ptr<Error> Clone() const override { return std::make_shared<CustomerKeyUnavailableError>(*this); }
1211 /** @endcond */
1212};
1213
1214MIP_NAMESPACE_END
1215
1216#endif // API_MIP_ERROR_H_
The user could not get access to the content.
Definition error.h:652
Adhoc protection should be set to complete the action on the file.
Definition error.h:1025
Bad input error, thrown when the input to an SDK API is invalid.
Definition error.h:247
ErrorCode GetErrorCode() const
Gets the errorCode of bad input.
Definition error.h:293
ErrorCode
ErrorCode of bad input error.
Definition error.h:253
@ General
General bad input error.
@ FileIsTooLargeForProtection
File is too large for protection.
@ ParameterParsing
Parameter cannot be parsed correctly.
@ LicenseNotTrusted
Publishing license not issued by trusted source.
@ DoubleKey
A paremeter for double key encryption is needed and missing.
@ FileFormatNotSupported
The input file's format is not supported.
An operation that required consent from user was not granted consent.
Definition error.h:936
Content Format is not supported.
Definition error.h:1109
Bring your own encryption key needed and unavailable.
Definition error.h:1196
Delegate Response Error.
Definition error.h:315
DelegateResponseError(const std::exception_ptr &except)
Creates an error/exception object.
Definition error.h:323
DelegateResponseError(const std::string &message, const std::string &stackTrace, const std::string &name="DelegateResponseError")
Creates an error/exception object.
Definition error.h:345
DelegateResponseError(const std::string &message, long HResult, const std::string &stackTrace, const std::string &name="DelegateResponseError")
Creates an error/exception object.
Definition error.h:362
DelegateResponseError(const std::string &message)
Creates an error/exception object.
Definition error.h:394
DelegateResponseError(const std::string &message, long HResult)
Creates an error/exception object.
Definition error.h:381
Caller invoked a deprecated API.
Definition error.h:1045
Base class for all errors that will be reported (thrown or returned) from MIP SDK.
Definition error.h:114
std::map< std::string, std::string > mDebugInfo
Definition error.h:225
const std::string & GetMessage(bool maskPII=false) const
Get the error message.
Definition error.h:151
void AddDebugInfo(const std::string &key, const std::string &value, bool sensitive=false)
Add debug info entry.
Definition error.h:179
const std::string & GetErrorName() const
Get the error name.
Definition error.h:144
virtual std::shared_ptr< Error > Clone() const =0
Clone the error.
char const * what() const noexcept override
Get the error message.
Definition error.h:121
std::string mName
Definition error.h:226
virtual ErrorType GetErrorType() const
Get the error type.
Definition error.h:137
ErrorType mType
Definition error.h:227
const std::map< std::string, std::string > & GetDebugInfo() const
Get debug info.
Definition error.h:192
std::string mMessage
Definition error.h:224
void SetMessage(const std::string &msg)
Set the error message.
Definition error.h:160
File IO error.
Definition error.h:442
Insufficient buffer error.
Definition error.h:421
Internal error.
Definition error.h:586
Label is disabled or inactive.
Definition error.h:1175
Label ID is not recognized.
Definition error.h:1131
License is not registered.
Definition error.h:1153
Networking error.
Definition error.h:462
Category GetCategory() const
Gets the category of network failure.
Definition error.h:523
Category
Category of network error.
Definition error.h:467
@ ServiceUnavailable
HTTP response code indicates service is unavailable.
@ BadResponse
HTTP response could not be read.
@ NoConnection
Failed to establish a connection.
@ Unknown
Unknown network failure.
@ UnexpectedResponse
HTTP response completed but contained unexpected data.
@ Offline
Operation requires network connectivity.
@ Cancelled
HTTP operation has been cancelled by the application.
@ FunctionNotImplemented
HTTP response code indicates called function is not implemented.
@ FailureResponseCode
HTTP response code indicates failure.
@ Timeout
Connection timed out.
@ Throttled
HTTP operation failed due to server traffic throttling.
@ Proxy
Proxy failure.
int32_t GetResponseStatusCode() const
Gets the HTTP response status code.
Definition error.h:530
The user could not get access to the content due to missing authentication token.
Definition error.h:853
The user could not get access to the content.
Definition error.h:672
Category GetCategory() const
Gets the category of no permissions failure.
Definition error.h:755
std::string GetOwner() const
Gets the owner of the document.
Definition error.h:748
Category
Category of no permissions error.
Definition error.h:677
@ AccessExpired
Access to content or action has expired.
@ UserNotFound
Requested user was not found failure.
@ NotOwner
User needs to be owner to perform action.
@ Unknown
Unknown no permissions failure.
@ NotPremiumLicenseUser
User needs to be a premium license holder to perform action.
@ ClientVersionNotSupported
User needs to update their client in order to support features used within this document >
@ AccessDenied
Access to content or action was not permitted.
std::string GetReferrer() const
Gets the contact in case of missing rights to the document.
Definition error.h:741
The user could not get access to the content due to extended Access checks like ABAC.
Definition error.h:782
Tenant policy is not configured for classification/labels.
Definition error.h:956
The operation requested by the application is not supported by the SDK.
Definition error.h:606
Operation was cancelled.
Definition error.h:1005
Current label was assigned as a privileged operation (The equivalent to an administrator operation),...
Definition error.h:632
Proxy authentication failure.
Definition error.h:559
The user could not get access to the content due to a service being disabled.
Definition error.h:874
Extent
Describes the extent for which the service is disabled.
Definition error.h:879
@ Platform
Service is disabled for the platform.
@ Tenant
Service is disabled for the tenant.
@ User
Service is disabled for the user.
@ Device
Service is disabled for the device.
Extent GetExtent() const
Gets the extent for which the service is disabled.
Definition error.h:916
Template ID is archived and unavailable for protection.
Definition error.h:1087
Template ID is not recognized by RMS service.
Definition error.h:1065
A file Containing the common types used by the upe, file and protection modules.
ErrorType
Definition error.h:74
@ NO_POLICY
No policy is configured for user/tenant.
@ LABEL_DISABLED
Label is disabled or inactive.
@ ADHOC_PROTECTION_REQUIRED
Adhoc protection should be set to complete the action on the file.
@ TEMPLATE_NOT_FOUND
Template ID is not recognized.
@ OPERATION_CANCELLED
Operation cancelled.
@ ACCESS_DENIED
The user could not get access to services.
@ PRIVILEGED_REQUIRED
Can't override privileged label when new label method is standard.
@ LICENSE_NOT_REGISTERED
License not registered for tracking and revocation.
@ NO_AUTH_TOKEN
The user could not get access to the content due to an empty auth token.
@ COUNT
Last element in this enum.
@ DISABLED_SERVICE
The user could not get access to the content due to the service being disabled.
@ FILE_IO_ERROR
General File IO error.
@ NETWORK_ERROR
General network issues; for example, unreachable service.
@ PROXY_AUTH_ERROR
Proxy authentication failed.
@ NO_PERMISSIONS
The user could not get access to the content.
@ LABEL_NOT_FOUND
Label ID is not recognized.
@ CONTENT_FORMAT_NOT_SUPPORTED
Content format is not supported.
@ CUSTOMER_KEY_UNAVAILABLE
Customer key not available when attempting to fetch for Bring Your Own Key Protection.
@ CONSENT_DENIED
An operation that required consent from user was not granted consent.
@ BAD_INPUT_ERROR
Caller passed bad input.
@ NOT_SUPPORTED_OPERATION
The requested operation is not yet supported.
@ JUSTIFICATION_REQUIRED
Justification should be provided to complete the action on the file.
@ INSUFFICIENT_BUFFER_ERROR
Caller passed a buffer that was too small.
@ DEPRECATED_API
Caller invoked a deprecated API.
@ DOUBLE_KEY_DISABLED
The double key feature has not been enabled.
@ TEMPLATE_ARCHIVED
Template has been archived and is unavailable for protection.
@ INTERNAL_ERROR
Internal unexpected errors.
@ DELEGATE_RESPONSE
Error generated from delegated response.
MIP namespace macros.
constexpr const char * GetErrorInfoCodesKey()
Definition error.h:64
constexpr const char * GetErrorInfoDetailsKey()
Definition error.h:68
constexpr const char * GetStackTraceString()
Definition error.h:50
constexpr const char * GetErrorInfoMessagesKey()
Definition error.h:66
constexpr const char * GetHResultString()
Definition error.h:54
constexpr const char * GetBadInputErrorString()
Definition error.h:58
constexpr const char * GetNoPermissionsExtendedErrorName()
Definition error.h:62
std::string code
Definition error.h:106
std::map< std::string, std::string > details
Definition error.h:108
std::string message
Definition error.h:107