Class that holds a formatted error message and potentially a set of detail messages. Error messages are intended to be user facing. Error details can be attached as strings to the message. These details should only be accessed internally.
| 51 | /// messages. Error messages are intended to be user facing. Error details can be attached |
| 52 | /// as strings to the message. These details should only be accessed internally. |
| 53 | class ErrorMsg { |
| 54 | public: |
| 55 | static constexpr int MAX_ERROR_MESSAGE_LEN = 128 * 1024; // 128kb |
| 56 | |
| 57 | typedef strings::internal::SubstituteArg ArgType; |
| 58 | |
| 59 | /// Trivial constructor. |
| 60 | ErrorMsg() : error_(TErrorCode::OK) {} |
| 61 | |
| 62 | /// Below are a set of overloaded constructors taking all possible number of arguments |
| 63 | /// that can be passed to Substitute. The reason is to try to avoid forcing the compiler |
| 64 | /// putting all arguments for Substitute() on the stack whenver this is called and thus |
| 65 | /// polute the instruction cache. |
| 66 | explicit ErrorMsg(TErrorCode::type error); |
| 67 | ErrorMsg(TErrorCode::type error, const ArgType& arg0); |
| 68 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1); |
| 69 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 70 | const ArgType& arg2); |
| 71 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 72 | const ArgType& arg2, const ArgType& arg3); |
| 73 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 74 | const ArgType& arg2, const ArgType& arg3, const ArgType& arg4); |
| 75 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 76 | const ArgType& arg2, const ArgType& arg3, const ArgType& arg4, |
| 77 | const ArgType& arg5); |
| 78 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 79 | const ArgType& arg2, const ArgType& arg3, const ArgType& arg4, |
| 80 | const ArgType& arg5, const ArgType& arg6); |
| 81 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 82 | const ArgType& arg2, const ArgType& arg3, const ArgType& arg4, |
| 83 | const ArgType& arg5, const ArgType& arg6, const ArgType& arg7); |
| 84 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 85 | const ArgType& arg2, const ArgType& arg3, const ArgType& arg4, |
| 86 | const ArgType& arg5, const ArgType& arg6, const ArgType& arg7, |
| 87 | const ArgType& arg8); |
| 88 | ErrorMsg(TErrorCode::type error, const ArgType& arg0, const ArgType& arg1, |
| 89 | const ArgType& arg2, const ArgType& arg3, const ArgType& arg4, |
| 90 | const ArgType& arg5, const ArgType& arg6, const ArgType& arg7, |
| 91 | const ArgType& arg8, const ArgType& arg9); |
| 92 | |
| 93 | /// Static initializer that is needed to avoid issues with static initialization order |
| 94 | /// and the point in time when the string list generated via thrift becomes |
| 95 | /// available. This method should not be used if no static initialization is needed as |
| 96 | /// the cost of this method is proportional to the number of entries in the global error |
| 97 | /// message list. |
| 98 | /// WARNING: DO NOT CALL THIS METHOD IN A NON STATIC CONTEXT |
| 99 | static ErrorMsg Init(TErrorCode::type error, const ArgType& arg0 = ArgType::kNoArg, |
| 100 | const ArgType& arg1 = ArgType::kNoArg, |
| 101 | const ArgType& arg2 = ArgType::kNoArg, |
| 102 | const ArgType& arg3 = ArgType::kNoArg, |
| 103 | const ArgType& arg4 = ArgType::kNoArg, |
| 104 | const ArgType& arg5 = ArgType::kNoArg, |
| 105 | const ArgType& arg6 = ArgType::kNoArg, |
| 106 | const ArgType& arg7 = ArgType::kNoArg, |
| 107 | const ArgType& arg8 = ArgType::kNoArg, |
| 108 | const ArgType& arg9 = ArgType::kNoArg); |
| 109 | |
| 110 | TErrorCode::type error() const { return error_; } |
no outgoing calls