# An explanation of LoadError: DomainError:?

**URL:** https://discourse.julialang.org/t/an-explanation-of-loaderror-domainerror/9408
**Category:** General Usage
**Created:** [March 1, 2018, 5:32am UTC](https://discourse.julialang.org/t/an-explanation-of-loaderror-domainerror/9408 "2018-03-01T05:32:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [March 1, 2018, 5:32am UTC](https://discourse.julialang.org/t/an-explanation-of-loaderror-domainerror/9408/1 "2018-03-01T05:32:12Z")

</div>

DomainError help is:

> The arguments to a function or constructor are outside the valid domain.

But I’m not sure of what constitutes “valid” and what the “domain” is?

I’m passing passing a macro generated struct as a argument between functions in different modules, and getting a domain error on some functions but not others with identical type signatures. It doesn’t give any indication of what the true problem is other than LoadError: DomainError: and a backtrace.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 1, 2018, 6:42am UTC](https://discourse.julialang.org/t/an-explanation-of-loaderror-domainerror/9408/2 "2018-03-01T06:42:47Z")

</div>

> [@Raf](#):
>
> what constitutes “valid” and what the “domain” is?

That’s up to the function. Eg for `sqrt`, the valid domain is positive real numbers.

Providing a minimal working example would allow giving you more specific advice.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [March 1, 2018, 8:11am UTC](https://discourse.julialang.org/t/an-explanation-of-loaderror-domainerror/9408/3 "2018-03-01T08:11:26Z")

</div>

Error on 0.7 is better, e.g.

```julia
julia> sqrt(-1)
ERROR: DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).

```

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [March 1, 2018, 11:08am UTC](https://discourse.julialang.org/t/an-explanation-of-loaderror-domainerror/9408/4 "2018-03-01T11:08:10Z")

</div>

Yes it was a square root in the end. That is a much better message in 0.7!
