From 50cec6cf46ce277b7a045466f96f3407cc537577 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Fri, 8 Nov 2024 19:11:05 +0100 Subject: [PATCH] FIX PDResultError never used --- src/playdate/scoreboards.nim | 5 ++++- tests/t_scoreboards.nim | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/playdate/scoreboards.nim b/src/playdate/scoreboards.nim index fdfbcf9..5c6b24a 100644 --- a/src/playdate/scoreboards.nim +++ b/src/playdate/scoreboards.nim @@ -61,7 +61,10 @@ template invokeCallback(callbackSeqs, value, errorMessage, freeValue, builder: u type ResultType = typeof(builder) let callback = callbackSeqs.pop() if value == nil: - callback(PDResult[ResultType](kind: PDResultUnavailable)) + if errorMessage == nil: + callback(PDResult[ResultType](kind: PDResultUnavailable)) + else: + callback(PDResult[ResultType](kind: PDResultError, message: $errorMessage)) else: try: let built = builder diff --git a/tests/t_scoreboards.nim b/tests/t_scoreboards.nim index 4fe41f9..cb76acc 100644 --- a/tests/t_scoreboards.nim +++ b/tests/t_scoreboards.nim @@ -11,7 +11,7 @@ proc execScoreboardTests*() = case score.kind of PDResultSuccess: echo $score.result of PDResultError: echo $score.message - of PDResultUnavailable: echo "SuccessEmpty" + of PDResultUnavailable: echo "PDResultUnavailable" test "addScore": playdate.scoreboards.addScore("some_board", 123) do (score: PDResult[PDScore]) -> void: