Re: Silencing errors when casting file to program

Chris Angelico <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <CAPTjJmrtqa5JmkzSjwrf+9aeO4zBvsTBtwu3RQd7F91ofoPfFA@mail.gmail.com>
On Sun, Oct 5, 2014 at 8:00 AM, Tor Edvardsson @ Pike  importmöte för
mailinglistan <[email protected]> wrote:
> So I'm casting a pike file to program and to make sure it compiles correctly I'm cathing any errors, like this
>
> mixed err = catch {
>   program p = (program) "some_app.pike";
> };

Personally, I don't bother with the cast shorthand unless I'm using
Hilfe. Try this:

void compile_error(string fn,int l,string msg) { }
void compile_warning(string fn,int l,string msg) { }
program is_compilable(string filename)
{
    program ret=UNDEFINED;
    catch {ret=compile_file(filename,this);};
    return ret;
}

That'll suppress the errors, courtesy of the 'handler' parameter to
compile_file().

ChrisA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.