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

use feature 'exceptions' #17

Open
schwern opened this issue Jan 27, 2015 · 0 comments
Open

use feature 'exceptions' #17

schwern opened this issue Jan 27, 2015 · 0 comments

Comments

@schwern
Copy link
Contributor

schwern commented Jan 27, 2015

autodie has too many features, weird interactions with Fatal, and internal methods that can be overridden. Adding internal exceptions is hard enough. Instead, make a new feature which causes all builtins to throw an exception on error. To ease forward compatibility a new CPAN module which is a wrapper around autodie (but does not reveal that) would be less problematic than trying to write a full autodie emulator.

All built in functions, not just IO. I don't think there's many outside IO. Basically anything that can return undef or print a warning is a candidate. Here's what I can think of right now...

  • eval STRING & evalbytes
    • If the code fails to compile.

That will break some eval idioms that are essentially "try this code". The trade off for protecting against code that's assumed to work is worth it.

  • File tests
    • If the file doesn't exist (except -e)
    • If the handle is closed or otherwise unreadable
    • If the stat or other important IO operation fails

This will break some file test idioms that assume you can do things like run -r on a file that doesn't exist. This may be a bad idea.

  • alarm?
  • printf, sprintf, pack, unpack
    • Invalid format/template
    • Invalid arguments for a given format
    • Missing arguments
  • substr
    • substring beyond the end of the string
  • caller
    • The level is off the stack
  • tie
    • TIEHASH fails to return an object.
  • gmtime, localtime
    • The given time is out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant