Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No fatal exceptions #4812

Closed
davidssmith opened this issue Nov 14, 2013 · 11 comments
Closed

No fatal exceptions #4812

davidssmith opened this issue Nov 14, 2013 · 11 comments

Comments

@davidssmith
Copy link
Contributor

Should there be an exception class that prints and error and then quits when thrown?

For example, this code seems to need to throw a fatal exception:

function check_blas()
    if blas_vendor() == :openblas
        openblas_config = openblas_get_config()
        openblas64 = ismatch(r".*USE64BITINT.*", openblas_config)
        if Base.USE_BLAS64 != openblas64
            if !openblas64
                println("ERROR: OpenBLAS was not built with 64bit integer support.")
                println("You're seeing this error because Julia was built with USE_BLAS64=1")
                println("Please rebuild Julia with USE_BLAS64=0")
            else
                println("ERROR: Julia was not built with support for OpenBLAS with 64bit integer support")
                println("You're seeing this error because Julia was built with USE_BLAS64=0")
                println("Please rebuild Julia with USE_BLAS64=1")
            end
            println("Quitting.")
            quit()
        end
    end
end
@ivarne
Copy link
Member

ivarne commented Nov 14, 2013

Are you requesting an exception that can not be caught? That seems kind of strange.

What about?

function quit(msg::String)
    println("Quitting.")
    println(msg)
    quit()
end

@davidssmith
Copy link
Contributor Author

It will be caught, but the default handler quits().

Is that strange?

On Thu, Nov 14, 2013 at 1:43 PM, Ivar Nesje notifications@github.comwrote:

Are you requesting an exception that can not be caught? That seems kind of
strange.

What about?

function quit(msg::String)
println("Quitting.")
println(msg)
quit()end


Reply to this email directly or view it on GitHubhttps://github.com//issues/4812#issuecomment-28515803
.

@ivarne
Copy link
Member

ivarne commented Nov 14, 2013

So user code can not catch your new exception?

If nobody catches an exception julia quits as it is now. Do you mean an exception that quits the REPL so that it does not give you a new prompt after showing the error and stacktrace?

@JeffBezanson
Copy link
Member

We try to avoid extra features wherever possible.

@davidssmith
Copy link
Contributor Author

I'm not proposing a new feature. I was wondering if all program exit
points should be consolidated into a FatalException handler.

On Thu, Nov 14, 2013 at 4:36 PM, Jeff Bezanson notifications@github.comwrote:

We try to avoid extra features wherever possible.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4812#issuecomment-28529908
.

@JeffBezanson
Copy link
Member

@StefanKarpinski @ViralBShah do you think we should add a FatalException type? It doesn't seem so necessary to me.

@StefanKarpinski
Copy link
Member

No. This is very uncommon. Almost every exception should be catchable. I do like @ivarne's idea of adding a method to quit that takes a message. That seems quite reasonable to me.

@vtjnash
Copy link
Member

vtjnash commented Nov 24, 2013

I can see an argument that this code should be allowed to cleanup, via the exception handlers, rather than just terminate:

julia> try
       quit()
       finally
       println("Bye")
       end
$ # where's my "Bye"?

But then all except blocks would need to be executed, and it's less clear if that is a good idea.

@ihnorton
Copy link
Member

ihnorton commented Feb 9, 2014

It would be nice to give the user a chance to see fatal errors before closing the REPL (I guess this is mainly an issue on Windows). Requested on list: https://groups.google.com/d/msg/julia-users/M5BTZtTUoz0/46wH40n0K0wJ

@vtjnash
Copy link
Member

vtjnash commented Mar 16, 2016

closing in favor of #15514

@vtjnash vtjnash closed this as completed Mar 16, 2016
@cossio
Copy link
Contributor

cossio commented Mar 16, 2016

In the example of @vtjnash, I think that the exception handlers should execute only if quit() throws an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants