# Dynamic dispatch in \`catch\` clauses

**URL:** <https://discourse.julialang.org/t/dynamic-dispatch-in-catch-clauses/4294>\
**Category:** General Usage\
**Created:** [June 15, 2017, 11:06pm UTC](https://discourse.julialang.org/t/dynamic-dispatch-in-catch-clauses/4294 "2017-06-15T23:06:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ulysses](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ulysses/32/665_2.png) [@ulysses](https://discourse.julialang.org/u/ulysses)\
**Post date:** [June 15, 2017, 11:06pm UTC](https://discourse.julialang.org/t/dynamic-dispatch-in-catch-clauses/4294/1 "2017-06-15T23:06:49Z")

</div>

Docs tell that one could create user-defined exception types simply subtyping `Exception`. But how to use those? In other languages we can use multiple `catch` clauses. Doesn’t Julia have ones?

```julia
struct MyEx <: Exception end

try
    # ...
catch (ex :: MyEx)
    println("My exception")
catch
    println("Any other exception")
end

```

---

<div class="post-metadata">

**Author:** ![Michael\_Eastwood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael_eastwood/32/669_2.png) [@Michael\_Eastwood](https://discourse.julialang.org/u/Michael_Eastwood)\
**Post date:** [June 15, 2017, 11:18pm UTC](https://discourse.julialang.org/t/dynamic-dispatch-in-catch-clauses/4294/2 "2017-06-15T23:18:05Z")

</div>

I think at the moment you need to do something like this:

```julia
julia> try
           error("foo")
       catch e
           if isa(e, ErrorException)
               println("bar")
           else
               rethrow(e)
           end
       end
bar

```
