Skip to content

Commit e50fa10

Browse files
committed
Added error handling.
1 parent 7d390e8 commit e50fa10

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nim/permutations.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import std/[strutils, cmdline]
22

3+
type InputArgumentError* = object of Exception
4+
35
proc printPermutations(a: var seq[string], n: int) =
46
if n <= 0:
57
echo a.join("\t")
@@ -12,4 +14,6 @@ proc printPermutations(a: var seq[string], n: int) =
1214

1315
when isMainModule:
1416
var args = commandLineParams()
17+
if len(args) == 0:
18+
raise newException(InputArgumentError, "ERROR: There must be at least 1 argument.")
1519
printPermutations(args, len(args) - 1)

0 commit comments

Comments
 (0)