Included error message in TargetControllerErrorOccurred event
This commit is contained in:
@@ -439,9 +439,10 @@ void TargetController::fireTargetEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
void TargetController::emitErrorEvent(int correlationId) {
|
||||
void TargetController::emitErrorEvent(int correlationId, const std::string& errorMessage) {
|
||||
auto errorEvent = std::make_shared<Events::TargetControllerErrorOccurred>();
|
||||
errorEvent->correlationId = correlationId;
|
||||
errorEvent->errorMessage = errorMessage;
|
||||
this->eventManager.triggerEvent(errorEvent);
|
||||
}
|
||||
|
||||
@@ -532,7 +533,7 @@ void TargetController::onStepTargetExecutionEvent(const Events::StepTargetExecut
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to step execution on target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,7 +554,7 @@ void TargetController::onResumeTargetExecutionEvent(const Events::ResumeTargetEx
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to resume execution on target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,7 +571,7 @@ void TargetController::onReadRegistersEvent(const Events::RetrieveRegistersFromT
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to read registers from target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +587,7 @@ void TargetController::onWriteRegistersEvent(const Events::WriteRegistersToTarge
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to write registers to target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,7 +601,7 @@ void TargetController::onReadMemoryEvent(const Events::RetrieveMemoryFromTarget&
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to read memory from target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -656,7 +657,7 @@ void TargetController::onWriteMemoryEvent(const Events::WriteMemoryToTarget& eve
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to write memory to target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,7 +671,7 @@ void TargetController::onSetBreakpointEvent(const Events::SetBreakpointOnTarget&
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to set breakpoint on target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,7 +685,7 @@ void TargetController::onRemoveBreakpointEvent(const Events::RemoveBreakpointOnT
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to remove breakpoint on target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,7 +705,7 @@ void TargetController::onSetProgramCounterEvent(const Events::SetProgramCounterO
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to set program counter on target - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,7 +739,7 @@ void TargetController::onRetrieveTargetPinStatesEvent(const Events::RetrieveTarg
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to retrieve target pin states - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -764,6 +765,6 @@ void TargetController::onSetPinStateEvent(const Events::SetTargetPinState& event
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to set target pin state for pin " + event.pinDescriptor.name + " - "
|
||||
+ exception.getMessage());
|
||||
this->emitErrorEvent(event.id);
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +251,9 @@ namespace Bloom
|
||||
* a correlation ID matching the ID of the event that triggered the handler.
|
||||
*
|
||||
* @param correlationId
|
||||
* @param errorMessage
|
||||
*/
|
||||
void emitErrorEvent(int correlationId);
|
||||
void emitErrorEvent(int correlationId, const std::string& errorMessage);
|
||||
|
||||
Targets::TargetDescriptor& getTargetDescriptor();
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ namespace Bloom
|
||||
const Events::SharedEventPointerNonConst<TriggerEventType> event,
|
||||
std::optional<std::chrono::milliseconds> timeout = {}
|
||||
) {
|
||||
using Bloom::Events::SharedEventPointer;
|
||||
using Bloom::Events::TargetControllerErrorOccurred;
|
||||
|
||||
using ResponseEventType = typename TriggerEventType::TargetControllerResponseType;
|
||||
|
||||
bool deRegisterEventType = false;
|
||||
@@ -68,7 +71,7 @@ namespace Bloom
|
||||
|
||||
auto responseEvent = this->eventListener.waitForEvent<
|
||||
ResponseEventType,
|
||||
Events::TargetControllerErrorOccurred
|
||||
TargetControllerErrorOccurred
|
||||
>(timeout.value_or(this->defaultTimeout), event->id);
|
||||
|
||||
if (deRegisterEventType) {
|
||||
@@ -79,11 +82,17 @@ namespace Bloom
|
||||
throw Bloom::Exceptions::Exception("Timed out waiting for response from TargetController.");
|
||||
}
|
||||
|
||||
if (!std::holds_alternative<Events::SharedEventPointer<ResponseEventType>>(responseEvent.value())) {
|
||||
throw Bloom::Exceptions::Exception("Unexpected response from TargetController");
|
||||
if (!std::holds_alternative<SharedEventPointer<ResponseEventType>>(responseEvent.value())) {
|
||||
if (std::holds_alternative<SharedEventPointer<TargetControllerErrorOccurred>>(responseEvent.value())) {
|
||||
auto& tcErrorEvent = std::get<SharedEventPointer<TargetControllerErrorOccurred>>(responseEvent.value());
|
||||
throw Bloom::Exceptions::Exception(tcErrorEvent->errorMessage);
|
||||
|
||||
} else {
|
||||
throw Bloom::Exceptions::Exception("Unexpected response from TargetController");
|
||||
}
|
||||
}
|
||||
|
||||
return std::get<Events::SharedEventPointer<ResponseEventType>>(responseEvent.value());
|
||||
return std::get<SharedEventPointer<ResponseEventType>>(responseEvent.value());
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user