From 1f36ecd0446295959b76ee77881d9a7e94b85f28 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 30 Dec 2022 18:43:39 +0100 Subject: [PATCH] LinkedList: Make expect_first() and expect_last() show a more accurate error description on panic Instead of showing a generic "Option::value() called on an empty Option" with no useful source location, you will get something like "check failed: m_start_node at LinkedList.h:139" --- luna/include/luna/LinkedList.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/luna/include/luna/LinkedList.h b/luna/include/luna/LinkedList.h index cb2e6c66..3c6bcb44 100644 --- a/luna/include/luna/LinkedList.h +++ b/luna/include/luna/LinkedList.h @@ -136,7 +136,8 @@ template class LinkedList T* expect_first() { - return first().value(); + check(m_start_node); + return m_start_node; } Option last() @@ -146,7 +147,8 @@ template class LinkedList T* expect_last() { - return last().value(); + check(m_end_node); + return m_end_node; } Option next(T* item)