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

Throw exceptions instead of erroring #64

Open
ElvishJerricco opened this issue Dec 26, 2014 · 4 comments
Open

Throw exceptions instead of erroring #64

ElvishJerricco opened this issue Dec 26, 2014 · 4 comments

Comments

@ElvishJerricco
Copy link
Member

There are several areas that can error in the process of compiling a method. I think I'd like to wrap several places in pcalls in such a way that the error message is converted to an exception and thrown. Mainly, there'd be a function called "ecall", that is used in the spots where methods get called. Its purpose is to call a method and if it errors, it will catch it from pcall, produce an exception built around the error message, and return nil, exception, effectively throwing the exception. Otherwise, it will return what the method returns.

@Turakar
Copy link
Contributor

Turakar commented Dec 26, 2014

That sounds good to me. A check in the callers side would still be necessary, wouldn't it? Because I would like to have exceptions just bubbeling up, like in Java.

EDIT: I hate auto-correction...

@Yevano
Copy link
Member

Yevano commented Dec 26, 2014

Because I would like to habe exceptions just bubbeling up, Mike in Java.

I don't even.

@Turakar
Copy link
Contributor

Turakar commented Dec 26, 2014

Well, it would probaby also be a lot oft recoding, so anyway.

@ElvishJerricco
Copy link
Member Author

The only thing that would change how it does its call I think would be the part of createCodeFunction that tailcalls the compiled method. Not at my computer at the moment so I can't copy paste but here's sort of how I think it'd look.

function createCodeFunction(blahParams)
    local rti, f
    return function(...)
        if not f then
            f, rti = compile(blahParams)
        end
        return ecall(f, ...)
    end
end

I don't think there's any other places that would need to be ecall'd

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

3 participants