# Use exception: MethodError: Cannot \`convert\` an object of type Vector{String} to an object of type String

**URL:** https://discourse.julialang.org/t/use-exception-methoderror-cannot-convert-an-object-of-type-vector-string-to-an-object-of-type-string/103669
**Category:** New to Julia
**Created:** [September 8, 2023, 2:12pm UTC](https://discourse.julialang.org/t/use-exception-methoderror-cannot-convert-an-object-of-type-vector-string-to-an-object-of-type-string/103669 "2023-09-08T14:12:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Leibniz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leibniz/32/217959_2.png) [@Leibniz](https://discourse.julialang.org/u/Leibniz)
#### Post date: [September 8, 2023, 2:12pm UTC](https://discourse.julialang.org/t/use-exception-methoderror-cannot-convert-an-object-of-type-vector-string-to-an-object-of-type-string/103669/1 "2023-09-08T14:12:00Z")

</div>

I try to use the DimensionMismatch excpetion [https://docs.julialang.org/en/v1/base/base/#Base.DimensionMismatch](https://docs.julialang.org/en/v1/base/base/#Base.DimensionMismatch)

` throw(DimensionMismatch(["\n some message \n"]))`  
gives  
`MethodError: Cannot `convert` an object of type Vector{String} to an object of type String`

I think the error message should not be a vector. Is this an error in the docs? How can I help with fixing this?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [September 8, 2023, 2:16pm UTC](https://discourse.julialang.org/t/use-exception-methoderror-cannot-convert-an-object-of-type-vector-string-to-an-object-of-type-string/103669/2 "2023-09-08T14:16:51Z")

</div>

The docstring is

```julia
DimensionMismatch([msg])

```

The braces `[]` signify that `msg` is optional - it does not mean that you need to pass an array.

For example, you can use either of these:

```julia
julia> throw(DimensionMismatch())
ERROR: DimensionMismatch: 
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

julia> throw(DimensionMismatch("my message"))
ERROR: DimensionMismatch: my message
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

```

though the second version is clearly more helpful/informative once a user encounters it.
