Skip to content

Commit

Permalink
FIX PDResultError never used
Browse files Browse the repository at this point in the history
  • Loading branch information
ninovanhooff committed Nov 8, 2024
1 parent bcdf181 commit 50cec6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/playdate/scoreboards.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/t_scoreboards.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 50cec6c

Please sign in to comment.