ceylon / ceylon-spec

DEPRECATED
Apache License 2.0
108 stars 34 forks source link

expose assertion annotations through `AssertionError` instances #1463

Open zamfofex opened 8 years ago

zamfofex commented 8 years ago

The title is pretty self explanatory. It means that if you have an assertion with annotations, the AssertionError thrown will contain the instances of the annotations' classes.

try
{
    "foo"
    bar baz qux assert(exists obj);
}
catch(AssertionError error)
{
    print(error.annotations);
}

The other day I was just thinking about how useless annotations in assertions are. It feels weird to allow such thing only so you can have the doc annotation there. I thought then: to solve the problem "they don't do anything", instead of disallowing them, why not make them actually do stuff?

gavinking commented 8 years ago

That's an interesting idea.