# \#exception

**URL:** https://discourse.julialang.org/tag/exception/155.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [InexactError vs OverflowError](https://discourse.julialang.org/t/inexacterror-vs-overflowerror/127108)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 3\
**Last updated:** [March 18, 2025, 7:05pm UTC](https://discourse.julialang.org/t/inexacterror-vs-overflowerror/127108 "2025-03-18T19:05:55Z")

</div>

I have a number type which throws when the result of a binary operation like + or \* is not representable in this type. I think InexactError is the right choice of exception, while OverflowError seems like a bad choice be…

---

## [DifferentialEquations.jl: Exception thrown in callback of solve command that is handled by a try-catch block inside another solve command causes the outer solve command to fail](https://discourse.julialang.org/t/differentialequations-jl-exception-thrown-in-callback-of-solve-command-that-is-handled-by-a-try-catch-block-inside-another-solve-command-causes-the-outer-solve-command-to-fail/126466)

<div class="topic-metadata">

**Author:** [@novalex98](https://discourse.julialang.org/u/novalex98)\
**Replies:** 8\
**Last updated:** [March 3, 2025, 6:26am UTC](https://discourse.julialang.org/t/differentialequations-jl-exception-thrown-in-callback-of-solve-command-that-is-handled-by-a-try-catch-block-inside-another-solve-command-causes-the-outer-solve-command-to-fail/126466 "2025-03-03T06:26:39Z")

</div>

I observed this with the latest version of julia, Running on a Windows 11 PC. tl dr: I have an exception being thrown in a callback for a solve command that’s inside another solve command. I have a try-catch block to ha…

---

## [New syntax suggestion: catch with type specs](https://discourse.julialang.org/t/new-syntax-suggestion-catch-with-type-specs/101840)

<div class="topic-metadata">

**Author:** [@HanD](https://discourse.julialang.org/u/HanD)\
**Replies:** 42\
**Last updated:** [February 21, 2025, 8:58pm UTC](https://discourse.julialang.org/t/new-syntax-suggestion-catch-with-type-specs/101840 "2025-02-21T20:58:47Z")

</div>

Hello! When using exceptions and try-catch blocks, it’s very common to handle some specific types of exceptions, and propagate everything else. Here’s how this is usually done: try # body with potential exceptions …

---

## [Should InexactError be thrown when converting from Int64 to Float64?](https://discourse.julialang.org/t/should-inexacterror-be-thrown-when-converting-from-int64-to-float64/124531)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 4\
**Last updated:** [January 9, 2025, 7:13am UTC](https://discourse.julialang.org/t/should-inexacterror-be-thrown-when-converting-from-int64-to-float64/124531 "2025-01-09T07:13:57Z")

</div>

Converting from Float64 to Int64 works fine if the number is an integer, otherwise a InexactError is thrown, and the user is required to use a function such as round or floor to perform the conversion in general. julia\> …

---

## [Embedded julia catch exception](https://discourse.julialang.org/t/embedded-julia-catch-exception/123287)

<div class="topic-metadata">

**Author:** [@Sergey](https://discourse.julialang.org/u/Sergey)\
**Replies:** 1\
**Last updated:** [December 3, 2024, 12:10pm UTC](https://discourse.julialang.org/t/embedded-julia-catch-exception/123287 "2024-12-03T12:10:16Z")

</div>

Hi. Im trying to use julia as user function extension. So i embed it into my qt application. But if there is an error in julia code everything will crash. Is it possible to catch julia exceptions from c++ or i could …

---

## [Is it possible to get an exception message as a string?](https://discourse.julialang.org/t/is-it-possible-to-get-an-exception-message-as-a-string/3201)

<div class="topic-metadata">

**Author:** [@izaid](https://discourse.julialang.org/u/izaid)\
**Replies:** 4\
**Last updated:** [April 14, 2017, 2:37am UTC](https://discourse.julialang.org/t/is-it-possible-to-get-an-exception-message-as-a-string/3201 "2017-04-14T02:37:32Z")

</div>

So, for language interop reasons, I’d like to translate Julia exceptions into a different kind of error. In the C API, it is pretty clear that jl\_exception\_occurred is what to use to check if an exception occurred or not…

---

## [What are the dangers of a possible proliferation of exception types?](https://discourse.julialang.org/t/what-are-the-dangers-of-a-possible-proliferation-of-exception-types/117310)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 7\
**Last updated:** [July 24, 2024, 4:33pm UTC](https://discourse.julialang.org/t/what-are-the-dangers-of-a-possible-proliferation-of-exception-types/117310 "2024-07-24T16:33:52Z")

</div>

I vaguely remember some advice about the necessity of being conservative with the number of different exception types. I can’t remember the rationale or find any on the Web, so I’m asking here. What’s wrong with having m…

---

## [PyPlot.show throws an exception (Win10 | Julia 1.10.0 )](https://discourse.julialang.org/t/pyplot-show-throws-an-exception-win10-julia-1-10-0/109156)

<div class="topic-metadata">

**Author:** [@Shamrock\_812](https://discourse.julialang.org/u/Shamrock_812)\
**Replies:** 11\
**Last updated:** [February 17, 2024, 4:26pm UTC](https://discourse.julialang.org/t/pyplot-show-throws-an-exception-win10-julia-1-10-0/109156 "2024-02-17T16:26:56Z")

</div>

New to Julia so possibly getting something all wrong here. When the Julia (1.10.0) script reaches Pyplot.show (line 107) the following exception is thrown. Laptop has Python 3.9.16 and Conda 23.1.0 installed. Any ideas? …

---

## [StaticCompiler - how to handle integer division error?](https://discourse.julialang.org/t/staticcompiler-how-to-handle-integer-division-error/108061)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 2\
**Last updated:** [December 27, 2023, 3:17am UTC](https://discourse.julialang.org/t/staticcompiler-how-to-handle-integer-division-error/108061 "2023-12-27T03:17:18Z")

</div>

StaticCompiler.jl does not allow exceptions. I got stuck trying to compile code involving the mod operator %, as it can raise an exception DivideError if you’re dividing by zero. How can I work around this?

---

## [Is it possible to suppress the chain of 'caused by' output when handling an exception?](https://discourse.julialang.org/t/is-it-possible-to-suppress-the-chain-of-caused-by-output-when-handling-an-exception/107823)

<div class="topic-metadata">

**Author:** [@johnomotani](https://discourse.julialang.org/u/johnomotani)\
**Replies:** 3\
**Last updated:** [December 19, 2023, 5:20pm UTC](https://discourse.julialang.org/t/is-it-possible-to-suppress-the-chain-of-caused-by-output-when-handling-an-exception/107823 "2023-12-19T17:20:27Z")

</div>

When handling an exception that was ‘caused by’ another exception, Julia prints out a stack of exceptions. Normally this is helpful, but in this case I want to handle the exception, and give the user a helpful message. I…

---

## [Stackoverflow error with no stacktrace](https://discourse.julialang.org/t/stackoverflow-error-with-no-stacktrace/105690)

<div class="topic-metadata">

**Author:** [@Larbino1](https://discourse.julialang.org/u/Larbino1)\
**Replies:** 3\
**Last updated:** [November 2, 2023, 1:21pm UTC](https://discourse.julialang.org/t/stackoverflow-error-with-no-stacktrace/105690 "2023-11-02T13:21:00Z")

</div>

I’m experienceing a strange bug which results in a stack overflow error with no stacktrace at all. I’m not sure how or why this happens, and I have found it impossible to diagnose. I haven’t been able to reprodruce the b…

---

## [Would it make sense to roll back module definitions which error half-way?](https://discourse.julialang.org/t/would-it-make-sense-to-roll-back-module-definitions-which-error-half-way/105228)

<div class="topic-metadata">

**Author:** [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Replies:** 0\
**Last updated:** [October 20, 2023, 11:25am UTC](https://discourse.julialang.org/t/would-it-make-sense-to-roll-back-module-definitions-which-error-half-way/105228 "2023-10-20T11:25:44Z")

</div>

Consider this: julia\> module M const a = 1 error("e") const b = 2 end ERROR: e Stacktrace: \[1\] error(s::String) @ Base ./error.jl:35 \[2\] top-level scope @ REPL\[1\]:3 julia\> M.a …

---

## [InlineDispatch.jl – A simple module to perform dispatch on the value of an expression](https://discourse.julialang.org/t/inlinedispatch-jl-a-simple-module-to-perform-dispatch-on-the-value-of-an-expression/102780)

<div class="topic-metadata">

**Author:** [@HanD](https://discourse.julialang.org/u/HanD)\
**Replies:** 0\
**Last updated:** [August 14, 2023, 6:41am UTC](https://discourse.julialang.org/t/inlinedispatch-jl-a-simple-module-to-perform-dispatch-on-the-value-of-an-expression/102780 "2023-08-14T06:41:08Z")

</div>

Based on a discussion here on Discourse, I’m happy to announce a new package called InlineDispatch.jl for dispatching on values using anonymous functions. The following expression: @dispatch expr begin v::T…

---

## [Is there a "gap" between acquire and try in the acquire-try-finally idiom?](https://discourse.julialang.org/t/is-there-a-gap-between-acquire-and-try-in-the-acquire-try-finally-idiom/96224)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 0\
**Last updated:** [March 17, 2023, 5:58am UTC](https://discourse.julialang.org/t/is-there-a-gap-between-acquire-and-try-in-the-acquire-try-finally-idiom/96224 "2023-03-17T05:58:11Z")

</div>

The prime motivation for finally clauses is to guarantee clean-up of resources like open files, locks, etc. For example, the Julia docs on finally clauses present the following example. f = open("file") try # operat…

---

## [Is it possible to catch a syntax error within the same file or REPL?](https://discourse.julialang.org/t/is-it-possible-to-catch-a-syntax-error-within-the-same-file-or-repl/95701)

<div class="topic-metadata">

**Author:** [@lmtzx9h4qqnt](https://discourse.julialang.org/u/lmtzx9h4qqnt)\
**Replies:** 0\
**Last updated:** [March 7, 2023, 10:41pm UTC](https://discourse.julialang.org/t/is-it-possible-to-catch-a-syntax-error-within-the-same-file-or-repl/95701 "2023-03-07T22:41:29Z")

</div>

Given the two files test.jl: f(; kwargs...) = dump(kwargs) try f(a=1, b=2, a=7) catch ex println("Caught exception!") dump(ex) end and testincl.jl: try include("test.jl") catch ex println("Caught exception!") …

---

## [Using @test\_throws for any error/excpeption](https://discourse.julialang.org/t/using-test-throws-for-any-error-excpeption/91609)

<div class="topic-metadata">

**Author:** [@HashBrown](https://discourse.julialang.org/u/HashBrown)\
**Replies:** 1\
**Last updated:** [December 13, 2022, 6:02pm UTC](https://discourse.julialang.org/t/using-test-throws-for-any-error-excpeption/91609 "2022-12-13T18:02:41Z")

</div>

I want to test that certain uses of my code throws an error, however I am not concerned with exactly what type of error. Is there a way to use @test\_throws without specifying the exact type of error?

---

## [System: caught exception of type](https://discourse.julialang.org/t/system-caught-exception-of-type/87538)

<div class="topic-metadata">

**Author:** [@jisutich](https://discourse.julialang.org/u/jisutich)\
**Replies:** 9\
**Last updated:** [September 25, 2022, 4:13pm UTC](https://discourse.julialang.org/t/system-caught-exception-of-type/87538 "2022-09-25T16:13:16Z")

</div>

Hi: Today I tried to install julia on a server but I faced the following error. I haven’t tried to run any codes or install any packages. This error just shows up after I installed julia on the server. Is there a way to…

---

## [Optim interface.jl type instability and efficient exception handling](https://discourse.julialang.org/t/optim-interface-jl-type-instability-and-efficient-exception-handling/84972)

<div class="topic-metadata">

**Author:** [@psterzinger](https://discourse.julialang.org/u/psterzinger)\
**Replies:** 0\
**Last updated:** [July 29, 2022, 11:32am UTC](https://discourse.julialang.org/t/optim-interface-jl-type-instability-and-efficient-exception-handling/84972 "2022-07-29T11:32:29Z")

</div>

Hi, I am currently trying to optimize a simulation that involves repeated parameter estimation, which I do with Optim.jl’s optimize with supplied gradients and hessians. interjace.jl type instability Looking at the fl…

---

## [How to use the built-in InvalidStateException](https://discourse.julialang.org/t/how-to-use-the-built-in-invalidstateexception/82408)

<div class="topic-metadata">

**Author:** [@Atiyah](https://discourse.julialang.org/u/Atiyah)\
**Replies:** 1\
**Last updated:** [June 9, 2022, 5:31am UTC](https://discourse.julialang.org/t/how-to-use-the-built-in-invalidstateexception/82408 "2022-06-09T05:31:19Z")

</div>

What would be a typical use case for employing the built-in InvalidStateException? Can this exception be employed for inconsistent values of different variables during runtime, i.e. invalid states or inconsistencies…

---

## [DifferentialEquations.jl precompilation error](https://discourse.julialang.org/t/differentialequations-jl-precompilation-error/58139)

<div class="topic-metadata">

**Author:** [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)\
**Replies:** 15\
**Last updated:** [October 19, 2021, 9:01am UTC](https://discourse.julialang.org/t/differentialequations-jl-precompilation-error/58139 "2021-10-19T09:01:21Z")

</div>

I’m getting this strange error when I try to compile DifferentialEquations.jl in VSCode. I’ve used this package before in VSCode without any issues; I’m not sure exactly what I did differently this time. The full stackt…

---

## [HTTP.request](https://discourse.julialang.org/t/http-request/67981)

<div class="topic-metadata">

**Author:** [@Laco\_Kovac](https://discourse.julialang.org/u/Laco_Kovac)\
**Replies:** 1\
**Last updated:** [September 10, 2021, 1:13pm UTC](https://discourse.julialang.org/t/http-request/67981 "2021-09-10T13:13:11Z")

</div>

I found very strange behaviour of HTTP.request call. My code looks like this: try result = HTTP.request(method, url, headers, body) catch e something end Server returns error, status 501 in my case, but it cou…

---

## [How to skip the error with try/catch statements?](https://discourse.julialang.org/t/how-to-skip-the-error-with-try-catch-statements/65527)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Replies:** 1\
**Last updated:** [July 30, 2021, 1:39am UTC](https://discourse.julialang.org/t/how-to-skip-the-error-with-try-catch-statements/65527 "2021-07-30T01:39:04Z")

</div>

Hi, Do you know how to try with another option when first doesn’t work? For example: try var = first\_option #this variable sometimes works, but in some cases throw an error #so, when this var throw an error, I want t…

---

## [How to find the error line using try/catch statements?](https://discourse.julialang.org/t/how-to-find-the-error-line-using-try-catch-statements/65511)

<div class="topic-metadata">

**Author:** [@Sebastian\_Mena](https://discourse.julialang.org/u/Sebastian_Mena)\
**Replies:** 6\
**Last updated:** [July 29, 2021, 10:03pm UTC](https://discourse.julialang.org/t/how-to-find-the-error-line-using-try-catch-statements/65511 "2021-07-29T22:03:16Z")

</div>

Hi, I want to get the line number of an error using try/catch statements. try \[my\_function\] catch err println(err) #this only shows the name of the error #i want to print the line number of the error I hope you can h…

---

## [Structuring a Type with Exception Messages](https://discourse.julialang.org/t/structuring-a-type-with-exception-messages/62127)

<div class="topic-metadata">

**Author:** [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Replies:** 7\
**Last updated:** [July 19, 2021, 8:57am UTC](https://discourse.julialang.org/t/structuring-a-type-with-exception-messages/62127 "2021-07-19T08:57:01Z")

</div>

I’m new to struct and have found parametric types a bit difficult to understand. I would like to constrain the admissible types and fail gracefully with intelligible messages. For instance, let’s say I only want to admi…

---

## [Does Julia have the Python equivalent of ValueError?](https://discourse.julialang.org/t/does-julia-have-the-python-equivalent-of-valueerror/62684)

<div class="topic-metadata">

**Author:** [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Replies:** 11\
**Last updated:** [June 10, 2021, 6:39pm UTC](https://discourse.julialang.org/t/does-julia-have-the-python-equivalent-of-valueerror/62684 "2021-06-10T18:39:04Z")

</div>

In Python, a specific exception exists called ValueError: Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more preci…

---

## [Help with register\_error\_hint](https://discourse.julialang.org/t/help-with-register-error-hint/56140)

<div class="topic-metadata">

**Author:** [@josePereiro](https://discourse.julialang.org/u/josePereiro)\
**Replies:** 5\
**Last updated:** [April 16, 2021, 6:34pm UTC](https://discourse.julialang.org/t/help-with-register-error-hint/56140 "2021-04-16T18:34:45Z")

</div>

Hi, I want to add some useful hints but for some reason I can’t trigger the callback for a UndefVarError exception. module Hinter only\_int(x::Int) = 1 any\_number(x::Number) = 2 function \_\_init\_\_() …

---

## [Always show exception type in stack trace?](https://discourse.julialang.org/t/always-show-exception-type-in-stack-trace/58010)

<div class="topic-metadata">

**Author:** [@tpgillam](https://discourse.julialang.org/u/tpgillam)\
**Replies:** 0\
**Last updated:** [March 26, 2021, 11:57am UTC](https://discourse.julialang.org/t/always-show-exception-type-in-stack-trace/58010 "2021-03-26T11:57:14Z")

</div>

I observe that stack traces in Julia do not necessarily show the type of the exception that is thrown. For example: julia\> throw(DomainError("moo")) ERROR: DomainError with moo: ...snip... includes “DomainError” in the…

---

## [Julia throws additional LoadError during exception handling](https://discourse.julialang.org/t/julia-throws-additional-loaderror-during-exception-handling/56446)

<div class="topic-metadata">

**Author:** [@jonasjonker](https://discourse.julialang.org/u/jonasjonker)\
**Replies:** 6\
**Last updated:** [March 4, 2021, 3:42pm UTC](https://discourse.julialang.org/t/julia-throws-additional-loaderror-during-exception-handling/56446 "2021-03-04T15:42:49Z")

</div>

I’m not really sure if this is the right place for this question, so please let me know where I should be if this is not the right place. I’m new to Julia, and I am writing some scripts that I’d like to use from the Lin…

---

## [PyError - with ExcelReaders perhaps](https://discourse.julialang.org/t/pyerror-with-excelreaders-perhaps/55092)

<div class="topic-metadata">

**Author:** [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Replies:** 1\
**Last updated:** [February 12, 2021, 7:12am UTC](https://discourse.julialang.org/t/pyerror-with-excelreaders-perhaps/55092 "2021-02-12T07:12:19Z")

</div>

Hello, I am getting an error with PyCall that I am having a hard time interpreting. I think that the error might be caused by using ExcelReaders . The other weird thing is that if I run my code one, it appears. If I run…

---

## [What's the differences between \`throw(ArgumentError(""))\` and \`return throw(ArgumentError("")\`)](https://discourse.julialang.org/t/whats-the-differences-between-throw-argumenterror-and-return-throw-argumenterror/51909)

<div class="topic-metadata">

**Author:** [@baddate](https://discourse.julialang.org/u/baddate)\
**Replies:** 1\
**Last updated:** [December 16, 2020, 11:23am UTC](https://discourse.julialang.org/t/whats-the-differences-between-throw-argumenterror-and-return-throw-argumenterror/51909 "2020-12-16T11:23:05Z")

</div>

i wrote a function that will throw an ArgumentError if it occurred any exception. but i have a question about throwing an error: i can use throw() directly, also i can use the return keyword. Is there any difference? …

[Next page](https://discourse.julialang.org/tag/exception/155.md?match_all_tags=true&page=1&tags%5B%5D=exception)
