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: