# Good error messages

**URL:** <https://discourse.julialang.org/t/good-error-messages/105523>\
**Category:** General Usage\
**Tags:** discussion\
**Created:** [October 28, 2023, 9:11pm UTC](https://discourse.julialang.org/t/good-error-messages/105523 "2023-10-28T21:11:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [October 28, 2023, 9:36pm UTC](https://discourse.julialang.org/t/good-error-messages/105523/2 "2023-10-28T21:36:48Z")

</div>

The `only` example makes me think the idea should be to give the _proof_ of the error condition.

> [@jules](#):
>
> We could print all the `elements` if there are at max let’s say five or so, but not after that as there could be way too many.

For `only`, we need to prove it has 2 elements, no more.

> [@jules](#):
>
> You could write the type instead of `Collection` but that might be a huge thing.

It would be nice to have a Base function `abbreviated_type` to use in error messages.

* * *

In [another post](https://discourse.julialang.org/t/make-julia-s-error-codes-even-better-than-elm-s/87409/3) I tried Elm style errors, and Mason came up with [a macro](https://discourse.julialang.org/t/make-julia-s-error-codes-even-better-than-elm-s/87409/51) to use like

```julia
function f(x::Real)
    if x>= 0.0
        x + 1
    else
        @noinline_block x throw(DomainError("f requires inputs greater than 0, you gave $x which is less than 0"))
    end
end

```

---

_[View the full topic](https://discourse.julialang.org/t/good-error-messages/105523)._
