| 130 | // ============================================================================ |
| 131 | |
| 132 | Error CodeEmitter::setLastError(Error error, const char* message) { |
| 133 | // This is fatal, CodeEmitter can't set error without being attached to `CodeHolder`. |
| 134 | ASMJIT_ASSERT(_code != nullptr); |
| 135 | |
| 136 | // Special case used to reset the last error. |
| 137 | if (error == kErrorOk) { |
| 138 | _lastError = kErrorOk; |
| 139 | _globalOptions &= ~kOptionMaybeFailureCase; |
| 140 | return kErrorOk; |
| 141 | } |
| 142 | |
| 143 | if (!message) |
| 144 | message = DebugUtils::errorAsString(error); |
| 145 | |
| 146 | // Logging is skipped if the error is handled by `ErrorHandler`. |
| 147 | ErrorHandler* handler = _code->_errorHandler; |
| 148 | if (handler && handler->handleError(error, message, this)) |
| 149 | return error; |
| 150 | |
| 151 | // The handler->handleError() function may throw an exception or longjmp() |
| 152 | // to terminate the execution of `setLastError()`. This is the reason why |
| 153 | // we have delayed changing the `_error` member until now. |
| 154 | _lastError = error; |
| 155 | _globalOptions |= kOptionMaybeFailureCase; |
| 156 | |
| 157 | return error; |
| 158 | } |
| 159 | |
| 160 | // ============================================================================ |
| 161 | // [asmjit::CodeEmitter - Helpers] |
no test coverage detected