# Way to get module of undef variable?

**URL:** <https://discourse.julialang.org/t/way-to-get-module-of-undef-variable/7931>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 22, 2017, 10:03pm UTC](https://discourse.julialang.org/t/way-to-get-module-of-undef-variable/7931 "2017-12-22T22:03:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [December 22, 2017, 10:03pm UTC](https://discourse.julialang.org/t/way-to-get-module-of-undef-variable/7931/1 "2017-12-22T22:03:25Z")

</div>

If you do:

```julia
cur_error = nothing 

try 
  foo(bar::Main.baz) = "Rambo"
catch tmp_error
  cur_error = tmp_error
end

```

which gives

```julia
> cur_error
UndefVarError(:baz)

> cur_error.var
:baz

```

* * *

The thing I’m kind of curious about is if there is a way to get the module that should have `:baz` in it (i.e. `Main`)?

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [December 24, 2017, 9:53pm UTC](https://discourse.julialang.org/t/way-to-get-module-of-undef-variable/7931/2 "2017-12-24T21:53:52Z")

</div>

Replaced by github issue:

[https://github.com/JuliaLang/julia/issues/25263](https://github.com/JuliaLang/julia/issues/25263)
