# Detect possible exceptions

**URL:** https://discourse.julialang.org/t/detect-possible-exceptions/64304
**Category:** General Usage
**Tags:** exceptions
**Created:** [July 8, 2021, 8:52pm UTC](https://discourse.julialang.org/t/detect-possible-exceptions/64304 "2021-07-08T20:52:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [July 8, 2021, 8:52pm UTC](https://discourse.julialang.org/t/detect-possible-exceptions/64304/1 "2021-07-08T20:52:54Z")

</div>

Suppose I want to have more confidence about the control flow in part of my program. Is it possible to detect what exceptions a function might throw?

E.g. is that something JET can do? @aviatesk

---

<div class="post-metadata">

### Author: ![aviatesk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aviatesk/32/7610_2.png) [@aviatesk](https://discourse.julialang.org/u/aviatesk)
#### Post date: [July 9, 2021, 2:24am UTC](https://discourse.julialang.org/t/detect-possible-exceptions/64304/2 "2021-07-09T02:24:38Z")

</div>

yes, but I’m wondering what kind of examples you have in mind.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [July 9, 2021, 2:55am UTC](https://discourse.julialang.org/t/detect-possible-exceptions/64304/3 "2021-07-09T02:55:17Z")

</div>

For example, it would be interesting to have a safe environment where no exceptions can happen and errors need to be managed by [ResultTypes.jl](https://github.com/iamed2/ResultTypes.jl).

```julia
function integer_division(x::Int, y::Int)::Result{Int, DivideError}
    if y == 0
        return DivideError()
    else
        return div(x, y)
    end
end

```

[https://doc.rust-lang.org/book/ch09-03-to-panic-or-not-to-panic.html](https://doc.rust-lang.org/book/ch09-03-to-panic-or-not-to-panic.html)

[https://crates.io/crates/no-panic/0.1.15/](https://crates.io/crates/no-panic/0.1.15/)

Or detect allocations that might result in out-of-memory errors.
