• ben (unregistered)

    turtles standing on top of turtles, but what does the frist turtle stand on?

  • Ziplodocus (unregistered)

    The first frist comment failed, this is the second attempt...

  • QJo (unregistered)
    class NothingCommenter : Exception, Commenter { 
     static public Exception Comment() { 
        return new NothingCommenter(); 
     } 
     
     public Exception LogComment() { 
         return NoComment; 
     } 
     
     private NothingCommenter() {} 
     } 
    
  • A Guy (unregistered)

    How can you type 'ExceptionLoggerLoggerLoggerLogger' without feeling stupid??

    And why did he stop at 4?

  • ANON (unregistered)

    Exceptional Indention Indention Indention

  • (cs)

    WTTTTTF!?

  • Caffeine (unregistered)

    Reminds me of the trace buster buster buster

    https://www.youtube.com/watch?v=Iw3G80bplTg&feature=kp

  • (cs)

    TRWTF is the logger inheriting from Exception.

  • james (unregistered) in reply to ben
    ben:
    turtles standing on top of turtles, but what does the frist turtle stand on?

    sorry, but its turtles all the way down!

    captcha "sagaciter", how appropriate :)

  • Mike R. (unregistered)

    The other extreme: Around here a lot of people just do this:

    try { ..... } catch ex { }

    When you ask, the most common answer is: "I don't want the application to crash."

  • hvd (unregistered)

    I haven't had any experience with Java performance troubleshooting, but do exception handlers really cause overhead, in the common case where no exceptions are thrown? I ask because they don't have to, and don't in other languages/environments: for C++ (depending on the ABI), for example, the runtime is able to detect whether there's a handler without the calling code having to waste instructions on setting up such a handler. And even if Java does have some noticeable cost for setting up the exception handler, how can the complexity of the handler be an issue if the handler isn't invoked?

  • anonymous (unregistered) in reply to hvd
    hvd:
    I haven't had any experience with Java performance troubleshooting, but do exception handlers really cause overhead, in the common case where no exceptions are thrown? I ask because they don't have to, and don't in other languages/environments: for C++ (depending on the ABI), for example, the runtime is able to detect whether there's a handler without the calling code having to waste instructions on setting up such a handler. And even if Java does have some noticeable cost for setting up the exception handler, how can the complexity of the handler be an issue if the handler isn't invoked?
    This is not Java, it's C#
  • William (unregistered)

    TRWTF is the utter lack of code review that allowed the greenhorn to commit that monstrosity and have it go to production.

  • ben (unregistered)
    sorry, but its turtles all the way down!
    That was implied; yes stopping at depth 4 is just lame.
  • Jim the Tool (unregistered)

    OO code is stupid, and people who code OO style are stupid. Exceptions are stupid. And so is your stupid face.

    In conclusion, this whole stupid WTF could have been avoided by using a decent and proper language that doesn't have stupid exceptions and stuff.

    Captcha uxor. I uxor to marry me, but she said she wouldn't marry a man who didn't code in C hash. I told her she was making a hash of it, and took the ring and married a man who knew BASIC instead.

  • anonymous (unregistered) in reply to A Guy
    A Guy:
    How can you type 'ExceptionLoggerLoggerLoggerLogger' without feeling stupid??
    Being a complete clueless moron?
  • (cs) in reply to hvd
    hvd:
    I haven't had any experience with Java performance troubleshooting, but do exception handlers really cause overhead, in the common case where no exceptions are thrown? I ask because they don't have to, and don't in other languages/environments: for C++ ...

    Every language I have encountered incurs some overhead of an exception handler being implemented, even if the exception is never thrown**. In many cases the overhead is so small it can be ignored (i.e. it may be on the order of sub-microsecond - but still non-zero).

    ** The exception (pun intended) is if the compiler can determine that the exception can not possibly be thrown. Under these conditions I have seen environments that optimize the try/catch out of existence (but then is the try/catch really implemented at all???)

  • Ziplodocus (unregistered) in reply to Jim the Tool
    Jim the Tool:
    OO code is stupid, and people who code OO style are stupid. Exceptions are stupid. And so is your stupid face.

    In conclusion, this whole stupid WTF could have been avoided by using a decent and proper language that doesn't have stupid exceptions and stuff.

    Captcha uxor. I uxor to marry me, but she said she wouldn't marry a man who didn't code in C hash. I told her she was making a hash of it, and took the ring and married a man who knew BASIC instead.

    Needs more discourse bashing...

  • (cs)

    The questions are quite reasonable. If more people put thought into error handling we would be struggling to fill the Friday Error'd column.

    The answer is, of course, wrong.

  • (cs)

    Thanks guys, I've got an earworm now.

    ExceptionLoggerLoggerLoggerLoggerLoggerLoggerLoggerLoggerMushroomMushroomSNAKE

  • fatfacemcfattypants (unregistered)

    I have made a similar pattern to this myself (honestly it needs some refactoring). I don't understand the intention in the example given above though.

    For for me it was due to three main factors:

    • The framework was not easy to work with in this regard (not exception based at all).
    • The system wraps exceptions when then reach the top layer where there is a split between exceptions with messages that should be shown to the user and those that should be suppressed. Exceptions with information not relevant to the user would log and end up wrapped in a UserException that provides a generic message with a hint of the log location should it be forwarded to a developer.
    • Because some communication systems propagated top level exceptions, existing exceptions thrown need to be converted to these exception types appropriately.

    In essence the system made it possible to use exceptions in a nice way and handled a lot of headaches automatically. For example, something like throw new UserException('You must enter a password'); would automatically propagate to the user with no need for developer input. Where as an unsafe exception type would have the message supressed. This kind of system has its ups and downs but worked pretty well for RAD.

    It logs excessively (about three times) but errors are infrequent enough that it's not a big concern for us yet.

  • sol (unregistered)

    On Error Resume Next

  • fatfacemcfattypants (unregistered) in reply to sol
    sol:
    On Error Resume Next

    Just use PHP it's built in.

  • Spanner number 3 (unregistered) in reply to Jim the Tool
    Jim the Tool:
    I uxor to marry me, but she said she wouldn't marry a man who didn't code in C hash. I told her she was making a hash of it, and took the ring and married a man who knew BASIC instead.

    C-pound, surely?

  • someguy (unregistered)

    I had to do a double-take after I read this since I saw it was posted by Erik Gern. It's probably the least "Gernified" post I've seen by him.

  • JustSomeDudette (unregistered)

    How many logs would a log exception log if log exception could log logs?

  • hvd (unregistered) in reply to anonymous
    anonymous:
    This is not Java, it's C#
    Oh wow, I can't believe I missed that. You're right. This coding style is more common in Java, and that threw me off, but the use of : for inheritance must be C#. Anyway, the same question still applies to C#.
    TheCPUWizard:
    Every language I have encountered incurs some overhead of an exception handler being implemented, even if the exception is never thrown**. In many cases the overhead is so small it can be ignored (i.e. it may be on the order of sub-microsecond - but still non-zero).
    Like I said, C++ compilers are capable of exceptions that have no overhead if not thrown. Consider
    void f1();
    void f2();
    void f3();
    void g() {
      try {
        f1();
      } catch (...) {
        f1();
      }
      try {
        f2();
      } catch (...) {
        f2();
      }
      try {
        f3();
      } catch (...) {
        f3();
      }
    }
    This compiles to
    g():
      pushq   %rbx
      call    f1()
      call    f2()
      call    f3()
      popq    %rbx
      ret
    for the success case, with GCC on an x86-64 Linux system. There are special assembler pseudo-instructions that produce metadata the runtime looks at to determine what to do should an exception be thrown, but unless an exception is thrown, the processor never sees it.
  • (cs) in reply to Spanner number 3
    Spanner number 3:
    Jim the Tool:
    I uxor to marry me, but she said she wouldn't marry a man who didn't code in C hash. I told her she was making a hash of it, and took the ring and married a man who knew BASIC instead.

    C-pound, surely?

    It's a hash (U+0023).

    No one outside the USA has ever used a hash as a Pound Symbol (£ U+00A3).

    A Sharp is U+266F.

  • Blah (unregistered)

    OK, the exception handling/logging is crazy. However, I would like to see more of the code where it was used. For the error handling to be a big bottleneck, I have to think that it's either worse than shown here or the code is throwing a ridiculous number of exceptions and there is a bigger WTF on the way.

  • ratis (unregistered)

    It's looooooooog, loooooooooog! It's big, it's heavy, it's wood! http://www.youtube.com/watch?v=RTrAVpK9blw

    LOL you can even make the infamous wooden table out of it.

  • Anomynous Misspeller (unregistered) in reply to anonymous
    anonymous:
    A Guy:
    How can you type 'ExceptionLoggerLoggerLoggerLogger' without feeling stupid??
    Being a complete clueless moron?

    TRWTF is the lack of code review at this company. Everybody is a complete clueless moron at some point in their career. Junior developers (i.e., "greenhorns") are not going to be experts out of the starting gate. This code should never have made it to the product. It should have been flagged in a code review and the greenhorn should have had good exception-catching practices explained to him.

  • anonymous (unregistered) in reply to Anomynous Misspeller
    Anomynous Misspeller:
    anonymous:
    A Guy:
    How can you type 'ExceptionLoggerLoggerLoggerLogger' without feeling stupid??
    Being a complete clueless moron?

    TRWTF is the lack of code review at this company. Everybody is a complete clueless moron at some point in their career. Junior developers (i.e., "greenhorns") are not going to be experts out of the starting gate. This code should never have made it to the product. It should have been flagged in a code review and the greenhorn should have had good exception-catching practices explained to him.

    Agreed. We all wrote crap code, it's part of learning the trade. But even being a newcomer, you must have had enough coding to realize that a LoggerLoggerLoggerLogger is something that at the very least raise an eyebrow. Heck, I'd bet that even my grandma would say "Loggawhat? And will that ever end?"

  • nmclean (unregistered) in reply to hvd
    hvd:
    I haven't had any experience with Java performance troubleshooting, but do exception handlers really cause overhead, in the common case where no exceptions are thrown? I ask because they don't have to, and don't in other languages/environments: for C++ (depending on the ABI), for example, the runtime is able to detect whether there's a handler without the calling code having to waste instructions on setting up such a handler. And even if Java does have some noticeable cost for setting up the exception handler, how can the complexity of the handler be an issue if the handler isn't invoked?
    This is true (for C#). So there is something missing from this story: why "error-catching code" was being called so commonly that it was a potential bottleneck in the first place.

    Is the handling of exceptions part of normal program flow? And if so, why are they logging those exceptions?

    And how does the fact that there are 4 layers of redundant loggers contribute to the bottleneck? Does LogMessage() actually fail?

  • dadude (unregistered)

    Yes and logger, logger, logger, logger, logger, logger, logger come back to me :)

  • (cs)

    Clearly the guy who wrote this always wanted to be a lumberjack.

    And that's okay.

  • Valued Service (unregistered) in reply to ben
    ben:
    turtles standing on top of turtles, but what does the frist turtle stand on?

    The last one of course.....

    Ouroboros...

  • (cs)

    Finally!! A story that does not end with "And Peter left the company shortly thereafter."

  • (cs) in reply to Medinoc
    Medinoc:
    TRWTF is the logger inheriting from Exception.

    Because in this case, it clearly should have inherited from Inception instead.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Spanner number 3
    Spanner number 3:
    Jim the Tool:
    I uxor to marry me, but she said she wouldn't marry a man who didn't code in C hash. I told her she was making a hash of it, and took the ring and married a man who knew BASIC instead.
    C-pound, surely?
    The cool kids call it C-hashtag.
  • (cs)

    Needs more polymorphism, so we could go…

    Logger logger logger logger logger chameleon, You throw and fail, You throw and faaaaaaail…

  • foo AKA fooo (unregistered) in reply to Caffeine
    Caffeine:
    Reminds me of the trace buster buster buster

    https://www.youtube.com/watch?v=Iw3G80bplTg&feature=kp

    Or the truck truck truck: http://www.youtube.com/watch?v=XVC8Jpb1PrA

  • foo AKA fooo (unregistered) in reply to someguy
    someguy:
    I had to do a double-take after I read this since I saw it was posted by Erik Gern. It's probably the least "Gernified" post I've seen by him.
    Well, I figured it was an EG article (without looking at the author line) because the training bit is clearly embellishment to fit the WTF, typical EG style.

    But it doesn't distract too much from the story and there is a real WTF after all.

    So for reference, in case EG is reading this (I know he isn't), this is just the acceptable level of embellishment. Not a little bit more than this.

  • Andrew (unregistered) in reply to ben
    ben:
    turtles standing on top of turtles, but what does the frist turtle stand on?

    the second turtle, duh.

  • anon (unregistered) in reply to ¯\(°_o)/¯ I DUNNO LOL
    ¯\(°_o)/¯ I DUNNO LOL:
    Spanner number 3:
    Jim the Tool:
    I uxor to marry me, but she said she wouldn't marry a man who didn't code in C hash. I told her she was making a hash of it, and took the ring and married a man who knew BASIC instead.
    C-pound, surely?
    The cool kids call it C-hashtag.

    A former boss called it "C-Plus".

    Captcha: similis; c-plus is similis to c-plus-plus.

  • (cs) in reply to Andrew
    Andrew:
    ben:
    turtles standing on top of turtles, but what does the frist turtle stand on?

    the second turtle, duh.

    Yes, but is it a male or female turtle?

  • Chelloveck (unregistered) in reply to ben
    ben:
    sorry, but its turtles all the way down!
    That was implied; yes stopping at depth 4 is just lame.

    The right way to do it, of course, is with a recursive logging method that will call itself again when an exception is thrown. Then you're sure that the system will do everything it possibly can to get that error message out.

  • (cs)

    Amazing. An Erik Gern story in which TRWTF is the code, not a ridiculous, overly embellished story. I approve. Perhaps there is hope for him yet.

  • Shakespere or something (unregistered)

    Those who don't know recursion are doomed to repeat it.

  • Paul Neumann (unregistered) in reply to dadude
    dadude:
    Yes and logger, logger, logger, logger, logger, logger, logger come back to me :)
    That's what the fox said!
  • Chris Angelico (unregistered)

    Logging can of course fail. Ever heard horror stories of a server that ran out of disk space when some log file filled it all up, and random daemons start having errors trying to log their errors? That's fun, especially when you can't SSH in because your SSH daemon logs all access... Do you have emergency solutions to crazy situations?

Leave a comment on “Exceptional Exception Logging Logging Logging”

Log In or post as a guest

Replying to comment #:

« Return to Article