smbache / ensurer

Ensure values are as expected at runtime
Other
84 stars 4 forks source link

More succinct errors: #7

Closed gaborcsardi closed 9 years ago

gaborcsardi commented 9 years ago

EDIT sorry, pressed enter by mistake.

I think being brief and succinct is a virtue. So how about

Errors: * all(. < 50)
        * all(.%%2 == 0)

instead of

Error:  The following condition(s) failed:
     * all(. < 50)
     * all(.%%2 == 0)
gaborcsardi commented 9 years ago

Obviously, I can do this for myself with fail_with, but I think it is something worth considering for the main package as wel.

smbache commented 9 years ago

Fair enough, except it's not strictly true.

gaborcsardi commented 9 years ago

You mean the form I used? Yes, indeed, it reads silly, actually, sorry about that.

The idea is not to waste a line, especially for a single failed condition, and to avoid the relatively lengthy text that essentially means "ERROR". But I cannot really say Assertions failed: with one short word. Plus it is probably a good idea to start with Error:. How about

Error: assertions failed:
        ✖ all(. < 50)
        ✖ all(.%%2 == 0)

for multiple failed assertions, and

Error: assertion failed: ✖ all(. < 50)

for single ones?

I am actually considering writing the checks in a way that they always fail with a single condition, for simplicity.

smbache commented 9 years ago

I will consider this a part of https://github.com/smbache/ensurer/issues/8, and close.