Coder Social home page Coder Social logo

Comments (7)

softmoth avatar softmoth commented on August 28, 2024

See the README for how to run the full tests. Do you have a suggestion of how to make this automatic for distributions?

from raku-template-mustache.

moritz avatar moritz commented on August 28, 2024

You could skip the tests that need them if the mustache specs aren't found.

from raku-template-mustache.

softmoth avatar softmoth commented on August 28, 2024

Fixed, thank you!

from raku-template-mustache.

softmoth avatar softmoth commented on August 28, 2024

Issue is not fixed, I can reproduce now with a fresh rakudo and panda build. It does not fail with OS X homebrew version This is perl6 version 2015.03 built on MoarVM version 2015.03.

Although the CATCH block is being called, the program still aborts. Here is a simplified test case:

my @files;
try {
    @files = dir('NONEXISTENT-DIR', :test(rx{ '.json' $ })).sort;
    note "After dir() call, which returned ", @files.perl;
    CATCH {
        @files = (); # Doesn't matter if this is here or not
        note "Caught an error reading nonexistent dir.";
    }
}

# This isn't reached
say "OK, files is ", @files.perl;

And result:

tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 (master %=)
[17:53:25] &4 $ perl6 --version
This is perl6 version 2015.04-112-gbcf3f1c built on MoarVM version 2015.04-24-g6ef0f8f

tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 (master %=)
[17:53:33] &4 $ perl6 t.pl6
Caught an error reading nonexistent dir.
Failed to get the directory contents of '/Users/tsmith/local/src/p6/panda/.panda-work/1430350453_1/NONEXISTENT-DIR': chdir failed: Unknown system error
  in method dir at src/gen/m-CORE.setting:19003
  in sub dir at src/gen/m-CORE.setting:19322
  in block <unit> at t.pl6:3

tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 !127 (master %=)
[17:53:49] &4 $ /usr/local/bin/perl6 --version
This is perl6 version 2015.03 built on MoarVM version 2015.03

tsmith@ganesha:~/local/src/p6/panda/.panda-work/1430350453_1 (master %=)
[17:53:55] &4 $ /usr/local/bin/perl6 t.pl6
After dir() call, which returned Array.new(Failure.new(exception => X::IO::Dir.new(path => "/Users/tsmith/local/src/p6/panda/.panda-work/1430350453_1/NONEXISTENT-DIR", os-error => "chdir failed: Unknown system error")))
OK, files is Array.new(Failure.new(exception => X::IO::Dir.new(path => "/Users/tsmith/local/src/p6/panda/.panda-work/1430350453_1/NONEXISTENT-DIR", os-error => "chdir failed: Unknown system error")))

from raku-template-mustache.

raydiak avatar raydiak commented on August 28, 2024

Putting a default { ... } block around the code inside the CATCH will fix it. This oversight was hidden by the fact that until recently, a 'try' didn't properly enforce 'use fatal', so your code would continue to run if it was a "soft" Failure, instead of an Exception.

As documented at http://design.perl6.org/S04.html#Exception_handlers , a CATCH is similar to a 'given' block, with the important difference that putting code directly in the block is not the same as having an actual default {}, because not "handling" the exception by an explicit when or default case will cause it to be rethrown. Hope that helps and makes sense. :)

from raku-template-mustache.

moritz avatar moritz commented on August 28, 2024

Since dir() produces a Failure, you don't even need a try/catch, you can do something like this:

my @files = given dir('NONEXISTENT-DIR', :test(rx{ '.json' $ })) {
    when Failure {
        note "Caught an error reading nonexistent dir.";
        ();
    }
    default {
        .sort;
    }
};

from raku-template-mustache.

softmoth avatar softmoth commented on August 28, 2024

Thank you, raydiak and moritz. Issue is actually fixed now, see a0bf17f.

from raku-template-mustache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.