From 9e9cc90af8355846c4ffed061c41d92881d2a19a Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 31 Mar 2014 21:59:30 -0500 Subject: [PATCH] add some error checking for when reading in the content of files --- .../redex/examples/benchmark/graph-data.rkt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/redex-pkgs/redex-examples/redex/examples/benchmark/graph-data.rkt b/pkgs/redex-pkgs/redex-examples/redex/examples/benchmark/graph-data.rkt index 174ed8e9cd..69b2d141c5 100644 --- a/pkgs/redex-pkgs/redex-examples/redex/examples/benchmark/graph-data.rkt +++ b/pkgs/redex-pkgs/redex-examples/redex/examples/benchmark/graph-data.rkt @@ -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