Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Have you head of Carp::Croak()?

Have you read the word optional? Why are you ignoring all other of my points? If you don't have an actual argument but just want to be right then say so, and I'll just shut up.

If you think that $foo eq 'Something' and $foo->isa( 'Something' ) are vastly different...you should be concerned.

I disagree. Strongly.

The bottom line is, either technique requires programmer discipline. If you really used 'MyError' for your exception namespace, you are just as vulnerable to someone else choosing that badly chosen namespace for their exceptions, as I would be if I used a non-specific formating convention for my error messages.

I disagree. First off, everything in programming requires discipline. Cooking and exception handling both require discipline, that doesn't make them identical. The big difference is that class namespaces are designed to be namespaces. Strings aren't. You can assume part of a string is a namespace, but you can never be sure. A class is always a namespace. It's designed for the job you want to cram into a string.

You also say yourself why strings are less reliable for error handling: It's depending on your error message formatting, *plus* the handling of errors by a type you want to extract from a free-form value that might have come from anywhere. With objects, all you need to check is the type. It doesn't matter then how I format my errors, how you format you errors, how I format your errors and how you format my errors.

If programmers adhere to a standard for their errors or exceptions, the problems are alleviated.

With object oriented exceptions, there are the enforced standards of objects. Specifically that data and package are separate pieces of information that I can access reliably. And as I've said earlier, if you're the only programmer working the code, and never upgrade your modules, and know all formats of errors all other authors used, then yes, it might "work."

But exceptions are not a magic bullet that will fix badly architected code.

Nothing will do that, but that's not an argument on the issue. I'd argue that inspecting user error messages for error type determination is bad code.


Ordinary morality is for ordinary people. -- Aleister Crowley

In reply to Re^14: eval to replace die? by phaylon
in thread eval to replace die? by hsmyers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-19 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found