# error.stack() not an array?

**URL:** <https://forum.xojo.com/t/error-stack-not-an-array/26041>\
**Category:** General\
**Created:** [August 13, 2015, 6:39pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041 "2015-08-13T18:39:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [August 13, 2015, 6:39pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041/1 "2015-08-13T18:39:05Z")

</div>

Error.stack is an array of strings.

So why (in app.UnhandledException event) can I do

```auto
MsgBox join( error.Stack, EndOfLine )
```

but not

```auto
MsgBox error.Stack( 0 )
```

I get “There is more than one item with this name and it is not clear to which this refers”

Very puzzled 

Markus

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [August 13, 2015, 6:46pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041/2 "2015-08-13T18:46:12Z")

</div>

It’s a method that returns an array. Your first line of code is equivalent to

```auto
dim e() as string = error.Stack()
Msgbox join(e, EndOfLine)
```

---

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [August 13, 2015, 6:59pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041/3 "2015-08-13T18:59:49Z")

</div>

Thanks, but I’m not quite sure what to make of what you said.

`Function UnhandledException(error As RuntimeException) As Boolean
  MsgBox join( error.Stack, EndOfLine ) // <- works
  MsgBox error.Stack( 0 ) // <- does NOT compile
End Function`

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [August 13, 2015, 7:09pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041/4 "2015-08-13T19:09:07Z")

</div>

MsgBox error.Stack( 0 ) // \<- does NOT compile

tries to pass a parameter (0) to a method that takes no parameters

IF it would compile you’d need something like

MsgBox error.Stack( )(0) // error.Stack returns an array of which you want the 0th element

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [August 13, 2015, 7:36pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041/5 "2015-08-13T19:36:17Z")

</div>

I was trying to point out the presence of an intermediate value, provided by the compiler. Your second line of code would have to be written using an explicit intermediate value, since the compiler cannot provide it for you.

```auto
dim e() as string = error.Stack()
Msgbox e(0)
```

---

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [August 13, 2015, 7:45pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041/6 "2015-08-13T19:45:22Z")

</div>

Thanks! Got it now.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:53pm UTC](https://forum.xojo.com/t/error-stack-not-an-array/26041/7 "2020-10-29T17:53:29Z")

</div>


