Used more specific exception classes to allow the TC to handle device failure errors better

This commit is contained in:
Nav
2021-08-15 01:47:48 +01:00
parent 89b5875132
commit 85fbf1ada4
16 changed files with 228 additions and 115 deletions

View File

@@ -1,5 +1,7 @@
#include "MplabSnap.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/TargetController/Exceptions/DeviceFailure.hpp"
#include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp"
using namespace Bloom::DebugToolDrivers;
using namespace Protocols::CmsisDap::Edbg::Avr;
@@ -46,7 +48,9 @@ std::string MplabSnap::getSerialNumber() {
);
if (response.getResponseId() != CommandFrames::Discovery::ResponseId::OK) {
throw Exception("Failed to fetch serial number from device - invalid Discovery Protocol response ID.");
throw DeviceInitializationFailure(
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
);
}
auto data = response.getPayloadData();
@@ -60,7 +64,7 @@ void MplabSnap::startSession() {
if (response.getResponseId() == CommandFrames::HouseKeeping::ResponseId::FAILED) {
// Failed response returned!
throw Exception("Failed to start session with MPLAB Snap!");
throw DeviceInitializationFailure("Failed to start session with MPLAB Snap!");
}
this->sessionStarted = true;
@@ -73,7 +77,7 @@ void MplabSnap::endSession() {
if (response.getResponseId() == CommandFrames::HouseKeeping::ResponseId::FAILED) {
// Failed response returned!
throw Exception("Failed to end session with MPLAB Snap!");
throw DeviceFailure("Failed to end session with MPLAB Snap!");
}
this->sessionStarted = false;