# Should failures of "assert" use \`~e\` to control printout length?

**URL:** <https://racket.discourse.group/t/should-failures-of-assert-use-e-to-control-printout-length/958>\
**Category:** Questions & Answers\
**Created:** [May 3, 2022, 5:59am UTC](https://racket.discourse.group/t/should-failures-of-assert-use-e-to-control-printout-length/958 "2022-05-03T05:59:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [May 3, 2022, 5:59am UTC](https://racket.discourse.group/t/should-failures-of-assert-use-e-to-control-printout-length/958/1 "2022-05-03T05:59:25Z")

</div>

Here's a program:

```scheme
#lang typed/racket

(assert (make-list 10000 "ouch")
        integer?)

```

The assertion fails... but then it takes 10 seconds or so to print out the error message. Should this error message be abbreviated? Is it as simple as using ~e in a format string somewhere?

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [May 4, 2022, 12:45pm UTC](https://racket.discourse.group/t/should-failures-of-assert-use-e-to-control-printout-length/958/2 "2022-05-04T12:45:20Z")

</div>

Yes, that sounds like the right thing to do. The implementation of assert should be easy to find with a right click.

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [May 5, 2022, 5:27am UTC](https://racket.discourse.group/t/should-failures-of-assert-use-e-to-control-printout-length/958/3 "2022-05-05T05:27:18Z")

</div>

On my way to fixing this, I ran into two more questions.

1. Should I add a test case, checking (say) that the error message for a particular assert is less than some length? Or is that not necessary?

2. in the following program, the source location of the type checking error is given as the #%module-begin. In other words, the whole file is highlighted. Is this a bug?

```scheme
#lang typed/racket

(require typed/rackunit)

(check < "hello" 14)

```

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [May 5, 2022, 5:35am UTC](https://racket.discourse.group/t/should-failures-of-assert-use-e-to-control-printout-length/958/4 "2022-05-05T05:35:01Z")

</div>

Adding my test case here so I don't forget it...

```scheme
#lang typed/racket

(require typed/rackunit)

(with-handlers ([exn:fail?
                 (λ ([e : exn])
                   (check < (string-length (exn-message e)) 400)
                   #f)])
  (assert (make-list 10000 "ouch")
          integer?)
  #f)

```
