# Get location and variable name from UndefVarError

**URL:** <https://discourse.julialang.org/t/get-location-and-variable-name-from-undefvarerror/102299>\
**Category:** General Usage\
**Created:** [July 31, 2023, 10:25am UTC](https://discourse.julialang.org/t/get-location-and-variable-name-from-undefvarerror/102299 "2023-07-31T10:25:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![t-anton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-anton/32/38981_2.png) [@t-anton](https://discourse.julialang.org/u/t-anton)\
**Post date:** [July 31, 2023, 10:25am UTC](https://discourse.julialang.org/t/get-location-and-variable-name-from-undefvarerror/102299/1 "2023-07-31T10:25:31Z")

</div>

Hi All,

How can I get an undefined variable name and its location?  
For example, in the code below

```julia
x = a +1

```

The output is:

```julia
UndefVarError: `a` not defined

Stacktrace:
 [1] top-level scope
   @ In[1]:1

```

How do I get out (from “Stacktrace”) the variable name and its location (row,column)? **What I would need is a tupel object (“a”,1,5)**

Thank you in advance

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [July 31, 2023, 11:19am UTC](https://discourse.julialang.org/t/get-location-and-variable-name-from-undefvarerror/102299/2 "2023-07-31T11:19:57Z")

</div>

For the variable name and line:

```julia
function foo()
    x = a + 1
end

global err;

s = try
        foo()
    catch err
        stacktrace(catch_backtrace())
    end

st = first(s);
(err.var, st.line)

```

I’m not sure how to get the column.

---

<div class="post-metadata">

**Author:** ![t-anton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-anton/32/38981_2.png) [@t-anton](https://discourse.julialang.org/u/t-anton)\
**Post date:** [August 2, 2023, 8:14pm UTC](https://discourse.julialang.org/t/get-location-and-variable-name-from-undefvarerror/102299/3 "2023-08-02T20:14:09Z")

</div>

How about column number?
