Skip to content

Commit

Permalink
Improve some error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
beef331 committed Feb 13, 2024
1 parent fd70962 commit e3a00d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions traitor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ macro genProcs(origTrait: typedesc): untyped =
let trait = origTrait[^1]
var tupl = trait.getTypeInst[^1].getTypeImpl()
if tupl.kind != nnkDistinctTy:
error("Trait is not a distinct tuple", tupl)
error("Provided trait is not a distinct tuple", tupl)
tupl = trait.instGenTree()

result = newStmtList()
Expand All @@ -356,7 +356,12 @@ macro doError(msg: static string, info: static InstInfo) =
var implementedTraits {.compileTime.}: seq[(NimNode, InstInfo)]

macro addTrait(t: typedesc, info: static InstInfo) =
if t.kind != nnkSym:
case t.kind
of nnkBracketExpr:
error("Expected '" & t[0].repr & "' but got '" & t.repr & "'", t)
of nnkSym:
discard
else:
error("Did not use a type alias for the trait tuple.", t)
implementedTraits.add (t, info)

Expand Down
2 changes: 1 addition & 1 deletion traitor.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.2.11"
version = "0.2.12"
author = "Jason Beetham"
description = "Trait-like package made without insight"
license = "MIT"
Expand Down

0 comments on commit e3a00d4

Please sign in to comment.