add some error checking for when reading in the content of files

This commit is contained in:
Robby Findler 2014-03-31 21:59:30 -05:00
parent 92b0e86ed1
commit 9e9cc90af8

View File

@ -98,10 +98,17 @@
(define data
(let ([raw-data
(apply append
(for/list ([f filenames])
(for/list ([f (in-list filenames)])
(call-with-input-file f
(λ (in)
(read in)))))])
(define ans (read in))
(unless (list? ans)
(error 'graph-data.rkt "expected a list in ~a, got ~v" f ans))
(unless (zero? (modulo (length ans) 3))
(error 'graph-data.rkt
"expected ~a's content's length to be a multiple of 3, got ~s"
f (length ans)))
ans))))])
(let loop ([fixed-data '()]
[rest raw-data])
(cond