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

Failure return from require when load fails #6677

Closed
p6rt opened this issue Feb 25, 2018 · 4 comments
Closed

Failure return from require when load fails #6677

p6rt opened this issue Feb 25, 2018 · 4 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Feb 25, 2018

Migrated from rt.perl.org#132909 (status was 'resolved')

Searchable as RT132909$

@p6rt
Copy link
Author

p6rt commented Feb 25, 2018

From @MARTIMM

Hi,

According to the documentation one should use the following to trap a
failure when loading a module fails using require;

try require :​:('Foo');
note :​:('Foo').Str if :​:('Foo') ~~ Failure;

The problem with this is that it isn't visible what is going wrong.
Using plain

require :​:('Foo');

an exception is thrown with a proper error and stack dump. However when
there are no errors in the module, there are other exceptions thrown
with messages like

WARNING​: unhandled Failure detected in DESTROY. If you meant to ignore it, you can mark it as handled by
 calling .Bool, .so, .not, or .defined methods. The Failure was​:
No such symbol 'Foo'
  in block at ... (...) line ...
...

This seems to me a bug. The only way to handle this properly is the
following

try {
  require :​:('Foo');

  ...

  CATCH {
  .note;
  }
}

Perl6 version​: 2018.01-195-g5ae1ca51f built on MoarVM version
2018.01-89-ga01cdb449 implementing Perl 6.c.

Regards,
Marcel

@p6rt
Copy link
Author

p6rt commented Mar 13, 2018

From @AlexDaniel

Pretty sure this is a dup of rakudo/rakudo#1515 , you can follow the progress on the issue there. Let us know if your problem is actually different.

Closing

On 2018-02-25 11​:11​:55, mt1957@​gmail.com wrote​:

Hi,

According to the documentation one should use the following to trap a
failure when loading a module fails using require;

try require :​:('Foo');
note :​:('Foo').Str if :​:('Foo') ~~ Failure;

The problem with this is that it isn't visible what is going wrong.
Using plain

require :​:('Foo');

an exception is thrown with a proper error and stack dump. However
when
there are no errors in the module, there are other exceptions thrown
with messages like

WARNING​: unhandled Failure detected in DESTROY. If you meant to ignore
it, you can mark it as handled by
 calling .Bool, .so, .not, or .defined methods. The Failure was​:
No such symbol 'Foo'
in block at ... (...) line ...
...

This seems to me a bug. The only way to handle this properly is the
following

try {
require :​:('Foo');

...

CATCH {
.note;
}
}

Perl6 version​: 2018.01-195-g5ae1ca51f built on MoarVM version
2018.01-89-ga01cdb449 implementing Perl 6.c.

Regards,
Marcel

@p6rt
Copy link
Author

p6rt commented Mar 13, 2018

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Mar 13, 2018

@AlexDaniel - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Mar 13, 2018
@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant