Skip to content

Commit e281572

Browse files
committed
Added card info to exception messages
1 parent 6b5da6e commit e281572

File tree

6 files changed

+32
-21
lines changed

6 files changed

+32
-21
lines changed

src/BarInterfaceBase.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class BarInterfaceBase : public BarInterface
131131
/// Convenience function for InfoLogger
132132
void log(const std::string& logMessage, ILMessageOption = LogInfoDevel);
133133

134+
/// Get a string descriptor, to be used for logs or exceptions
135+
const std::string &getLoggerPrefix() {
136+
return mLoggerPrefix;
137+
};
138+
134139
private:
135140
/// Inheriting classes must implement this to check whether a given read is safe.
136141
/// If it is not safe, it should throw an UnsafeReadAccess exception

src/Crorc/CrorcBar.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void CrorcBar::assertLinkUp()
191191
}
192192

193193
if (!checkLinkUp()) {
194-
BOOST_THROW_EXCEPTION(CrorcCheckLinkException() << ErrorInfo::Message("Link was not up"));
194+
BOOST_THROW_EXCEPTION(CrorcCheckLinkException() << ErrorInfo::Message(getLoggerPrefix() + "Link was not up"));
195195
}
196196
}
197197

@@ -238,7 +238,7 @@ bool CrorcBar::getDynamicOffsetEnabled()
238238
void CrorcBar::setTimeFrameLength(uint16_t timeFrameLength)
239239
{
240240
if (timeFrameLength > 256) {
241-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("BAD TF LENGTH, should be less or equal to 256") << ErrorInfo::ConfigValue(timeFrameLength));
241+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "BAD TF LENGTH, should be less or equal to 256") << ErrorInfo::ConfigValue(timeFrameLength));
242242
}
243243
modifyRegister(Crorc::Registers::CFG_CONTROL_B.index, 0, 11, timeFrameLength);
244244
}
@@ -299,7 +299,7 @@ void CrorcBar::sendDdlCommand(uint32_t address, uint32_t command)
299299
while ((std::chrono::steady_clock::now() < timeOut) && !checkFifoEmpty()) {
300300
}
301301
if (!checkFifoEmpty()) {
302-
BOOST_THROW_EXCEPTION(CrorcCheckLinkException() << ErrorInfo::Message("Link was not up"));
302+
BOOST_THROW_EXCEPTION(CrorcCheckLinkException() << ErrorInfo::Message(getLoggerPrefix() + "Link was not up"));
303303
} else {
304304
readRegister(Crorc::Registers::DDL_STATUS.index);
305305
}

src/Crorc/CrorcDmaChannel.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ CrorcDmaChannel::CrorcDmaChannel(const Parameters& parameters)
4141
{
4242
// Check that the DMA page is valid
4343
if (mPageSize != DMA_PAGE_SIZE) {
44-
BOOST_THROW_EXCEPTION(CrorcException() << ErrorInfo::Message("CRORC only supports 8KiB DMA page size")
44+
BOOST_THROW_EXCEPTION(CrorcException() << ErrorInfo::Message(getLoggerPrefix() + "CRORC only supports 8KiB DMA page size")
4545
<< ErrorInfo::DmaPageSize(mPageSize));
4646
}
4747

4848
// Check that the data source is valid. If not throw
4949
if (mDataSource == DataSource::Ddg) {
50-
BOOST_THROW_EXCEPTION(CruException() << ErrorInfo::Message("CRORC does not support specified data source")
50+
BOOST_THROW_EXCEPTION(CruException() << ErrorInfo::Message(getLoggerPrefix() + "CRORC does not support specified data source")
5151
<< ErrorInfo::DataSource(mDataSource));
5252
}
5353

@@ -76,7 +76,7 @@ CrorcDmaChannel::CrorcDmaChannel(const Parameters& parameters)
7676
if (entry.size < kSuperpageInfoSize) {
7777
// Something must've failed at some point
7878
BOOST_THROW_EXCEPTION(Exception()
79-
<< ErrorInfo::Message("Scatter gather list entry for Superpage info buffer was too small")
79+
<< ErrorInfo::Message(getLoggerPrefix() + "Scatter gather list entry for Superpage info buffer was too small")
8080
<< ErrorInfo::ScatterGatherEntrySize(entry.size)
8181
<< ErrorInfo::SuperpageInfoSize(kSuperpageInfoSize));
8282
}
@@ -220,7 +220,7 @@ int CrorcDmaChannel::getReadyQueueSize()
220220
auto CrorcDmaChannel::getSuperpage() -> Superpage
221221
{
222222
if (mReadyQueue.isEmpty()) {
223-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not get superpage, ready queue was empty"));
223+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not get superpage, ready queue was empty"));
224224
}
225225
return *mReadyQueue.frontPtr();
226226
}
@@ -234,7 +234,7 @@ bool CrorcDmaChannel::pushSuperpage(Superpage superpage)
234234
checkSuperpage(superpage);
235235

236236
if (mTransferQueue.sizeGuess() >= TRANSFER_QUEUE_CAPACITY) {
237-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not push superpage, transfer queue was full"));
237+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not push superpage, transfer queue was full"));
238238
}
239239

240240
mTransferQueue.write(superpage);
@@ -245,7 +245,7 @@ bool CrorcDmaChannel::pushSuperpage(Superpage superpage)
245245
auto CrorcDmaChannel::popSuperpage() -> Superpage
246246
{
247247
if (mReadyQueue.isEmpty()) {
248-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not pop superpage, ready queue was empty"));
248+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not pop superpage, ready queue was empty"));
249249
}
250250
auto superpage = mReadyQueue.frontPtr();
251251
mReadyQueue.popFront();

src/Cru/CruBar.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ uint32_t CruBar::getSuperpageSize(uint32_t link)
176176
uint32_t CruBar::getSuperpageFifoEmptyCounter(uint32_t link)
177177
{
178178
if (link >= Cru::MAX_LINKS) {
179-
BOOST_THROW_EXCEPTION(InvalidLinkId() << ErrorInfo::Message("Link ID out of range") << ErrorInfo::LinkId(link));
179+
BOOST_THROW_EXCEPTION(InvalidLinkId() << ErrorInfo::Message(getLoggerPrefix() + "Link ID out of range") << ErrorInfo::LinkId(link));
180180
}
181181
return readRegister(Cru::Registers::LINK_SUPERPAGE_FIFO_EMPTY.get(link).index);
182182
}
@@ -720,7 +720,7 @@ Cru::TriggerMonitoringInfo CruBar::monitorTriggers(bool updateable)
720720
void CruBar::checkConfigParameters()
721721
{
722722
if (mUserAndCommonLogicEnabled && !mUserLogicEnabled) {
723-
BOOST_THROW_EXCEPTION(ParameterException() << ErrorInfo::Message("User and Common logic switch invalid when User logic disabled"));
723+
BOOST_THROW_EXCEPTION(ParameterException() << ErrorInfo::Message(getLoggerPrefix() + "User and Common logic switch invalid when User logic disabled"));
724724
}
725725
}
726726

src/Cru/CruDmaChannel.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ CruDmaChannel::CruDmaChannel(const Parameters& parameters)
4040
if (pageSize.get() != Cru::DMA_PAGE_SIZE) {
4141
log("DMA page size not default; Behaviour undefined", LogWarningDevel_(4250));
4242
/*BOOST_THROW_EXCEPTION(CruException()
43-
<< ErrorInfo::Message("CRU only supports an 8KiB page size")
43+
<< ErrorInfo::Message(getLoggerPrefix() + "CRU only supports an 8KiB page size")
4444
<< ErrorInfo::DmaPageSize(pageSize.get()));*/
4545
}
4646
}
4747

4848
if (mDataSource == DataSource::Diu || mDataSource == DataSource::Siu) {
49-
BOOST_THROW_EXCEPTION(CruException() << ErrorInfo::Message("CRU does not support specified data source")
49+
BOOST_THROW_EXCEPTION(CruException() << ErrorInfo::Message(getLoggerPrefix() + "CRU does not support specified data source")
5050
<< ErrorInfo::DataSource(mDataSource));
5151
}
5252

@@ -99,7 +99,7 @@ CruDmaChannel::CruDmaChannel(const Parameters& parameters)
9999
log(stream.str(), LogInfoDevel_(4252));
100100

101101
if (mLinks.empty()) {
102-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("No links are enabled. Check with roc-status. Configure with roc-config."));
102+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "No links are enabled. Check with roc-status. Configure with roc-config."));
103103
}
104104

105105
mReadyQueue = std::make_unique<SuperpageQueue>(mReadyQueueCapacity + 1); // folly queue needs + 1
@@ -214,7 +214,7 @@ void CruDmaChannel::deviceResetChannel(ResetLevel::type resetLevel)
214214
if (resetLevel == ResetLevel::Nothing) {
215215
return;
216216
} else if (resetLevel != ResetLevel::Internal) {
217-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("The CRU can only be reset internally"));
217+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "The CRU can only be reset internally"));
218218
}
219219
resetCru();
220220
}
@@ -260,7 +260,7 @@ bool CruDmaChannel::pushSuperpage(Superpage superpage)
260260
if (mLinkQueuesTotalAvailable == 0) {
261261
// Note: the transfer queue refers to the firmware, not the mLinkIndexQueue which contains the LinkIds for links
262262
// that can still be pushed into (essentially the opposite of the firmware's queue).
263-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not push superpage, transfer queue was full"));
263+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not push superpage, transfer queue was full"));
264264
}
265265

266266
// Get the next link to push
@@ -269,7 +269,7 @@ bool CruDmaChannel::pushSuperpage(Superpage superpage)
269269
if (link.queue->sizeGuess() >= mLinkQueueCapacity) {
270270
// Is the link's FIFO out of space?
271271
// This should never happen
272-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not push superpage, link queue was full"));
272+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not push superpage, link queue was full"));
273273
}
274274

275275
// Once we've confirmed the link has a slot available, we push the superpage
@@ -286,15 +286,15 @@ bool CruDmaChannel::pushSuperpage(Superpage superpage)
286286
auto CruDmaChannel::getSuperpage() -> Superpage
287287
{
288288
if (mReadyQueue->isEmpty()) {
289-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not get superpage, ready queue was empty"));
289+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not get superpage, ready queue was empty"));
290290
}
291291
return *mReadyQueue->frontPtr();
292292
}
293293

294294
auto CruDmaChannel::popSuperpage() -> Superpage
295295
{
296296
if (mReadyQueue->isEmpty()) {
297-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not pop superpage, ready queue was empty"));
297+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not pop superpage, ready queue was empty"));
298298
}
299299
auto superpage = *mReadyQueue->frontPtr();
300300
mReadyQueue->popFront();
@@ -311,7 +311,7 @@ void CruDmaChannel::pushSuperpageToLink(Link& link, const Superpage& superpage)
311311
void CruDmaChannel::transferSuperpageFromLinkToReady(Link& link, bool reclaim)
312312
{
313313
if (link.queue->isEmpty()) {
314-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not transfer Superpage from link to ready queue, link queue is empty"));
314+
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message(getLoggerPrefix() + "Could not transfer Superpage from link to ready queue, link queue is empty"));
315315
}
316316

317317
if (!reclaim) {
@@ -353,7 +353,7 @@ void CruDmaChannel::fillSuperpages()
353353
<< superpageCount << " pushed according to firmware";
354354
log(stream.str(), LogErrorDevel_(4256));
355355
BOOST_THROW_EXCEPTION(Exception()
356-
<< ErrorInfo::Message("FATAL: Firmware reported more superpages available than should be present in FIFO"));
356+
<< ErrorInfo::Message(getLoggerPrefix() + "FATAL: Firmware reported more superpages available than should be present in FIFO"));
357357
}
358358

359359
while (amountAvailable) {

src/DmaChannelBase.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ class DmaChannelBase : public DmaChannelInterface
129129

130130
protected:
131131
std::string mLoggerPrefix;
132+
133+
/// Get a string descriptor, to be used for logs or exceptions
134+
const std::string &getLoggerPrefix() {
135+
return mLoggerPrefix;
136+
};
137+
132138
};
133139

134140
} // namespace roc

0 commit comments

Comments
 (0)