# Best practices for error trapping and exception handling in Julia as of mid 2022

**URL:** https://discourse.julialang.org/t/best-practices-for-error-trapping-and-exception-handling-in-julia-as-of-mid-2022/88754
**Category:** General Usage
**Tags:** question
**Created:** [October 14, 2022, 8:59pm UTC](https://discourse.julialang.org/t/best-practices-for-error-trapping-and-exception-handling-in-julia-as-of-mid-2022/88754 "2022-10-14T20:59:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)
#### Post date: [October 14, 2022, 8:59pm UTC](https://discourse.julialang.org/t/best-practices-for-error-trapping-and-exception-handling-in-julia-as-of-mid-2022/88754/1 "2022-10-14T20:59:45Z")

</div>

Hey folks. I was trying to identify some best practices around error trapping or exception handling in Julia as of today, or at least mid-2022. I have found a bunch of blog posts on exception handling in Julia, for [example](https://scls.gitbooks.io/ljthw/content/_chapters/11-ex8.html). Here is another [example](https://www.juliabloggers.com/managing-exceptions-with-resulttypes/). But I imagine that may of the recommended packages might be out of date, or may have been superseded by better packages, etc.

hence I was hoping that the community might identify or recommend some best practices and packages for error trapping or exception handling in julia. This can include anything from packages for nicer error messages, to more performant try/catch blocks, etc.

Thanks.

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [October 14, 2022, 9:04pm UTC](https://discourse.julialang.org/t/best-practices-for-error-trapping-and-exception-handling-in-julia-as-of-mid-2022/88754/2 "2022-10-14T21:04:43Z")

</div>

FYI: There’s also (I recalled a package having Go-like error handling, maybe I misremember, and had this one in mind):

> **[GitHub - jakobnissen/ErrorTypes.jl: Rust-like error types in Julia](https://github.com/jakobnissen/ErrorTypes.jl)**
>
> Rust-like error types in Julia. Contribute to jakobnissen/ErrorTypes.jl development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)
#### Post date: [October 14, 2022, 9:11pm UTC](https://discourse.julialang.org/t/best-practices-for-error-trapping-and-exception-handling-in-julia-as-of-mid-2022/88754/3 "2022-10-14T21:11:53Z")

</div>

@Palli Oh yes, this is great. I really love Rust exception handling, it is really the best that I have ever seen. I will look at this package.

---

<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 14, 2022, 10:48pm UTC](https://discourse.julialang.org/t/best-practices-for-error-trapping-and-exception-handling-in-julia-as-of-mid-2022/88754/4 "2022-10-14T22:48:13Z")

</div>

Try.jl uses a union instead of a Result{R,E} which I think is better for Julia.

> **[GitHub - JuliaPreludes/Try.jl: Zero-overhead and debuggable error handling](https://github.com/JuliaPreludes/Try.jl)**
>
> Zero-overhead and debuggable error handling. Contribute to JuliaPreludes/Try.jl development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)
#### Post date: [October 15, 2022, 6:53am UTC](https://discourse.julialang.org/t/best-practices-for-error-trapping-and-exception-handling-in-julia-as-of-mid-2022/88754/5 "2022-10-15T06:53:52Z")

</div>

@jar1 thanks for pointing out this package. Yeah, the setup looks very nice.
