The `assert` is very handy statement, but when it fails there's **no info why 
it failed**.
    
    
    let a = 1
    let b = 2
    
    assert a == b
    
    
    Run

Error:
    
    
    Error: unhandled exception: /usercode/in.nim(4, 8) `a == b`  
[AssertionDefect]
    
    
    Run

And when you see such assert error in console, you usually need to do:

  * Go to source and find where this assert is defined
  * Add `echo a, b`
  * Run program again
  * If it's server, you need to re-create all the condition to hit it



Lot of boring work. Would be better if `assert` would also **tell us why it 
failed**.

For example, if assert is used for equality test `assert a == b` and if string 
representations of `$a` and `$b` are short - print it along with the error.

Or, if it's not desirable for the `assert` default behavior, allow to extend it 
with `assert_hook`, something like `when compile(assert_hook(a, b)): 
assert_hook(a, b)`.

Reply via email to