1 Reply Latest reply on Dec 10, 2015 9:31 AM by adinn

    Will AT THROW catch Throwable Block

    mahesh.shet

      Hi,

       

      In one of the code i see the following catch block:

       

      } catch (SomeException e) {

        .....................

      } catch (Throwable ex) {

        log.error("Unknown exception occured ...........", ex);

        .............

      }

       

      Can I trigger the Throwable ex action from Byteman?

        • 1. Re: Will AT THROW catch Throwable Block
          adinn

          Hi Mahesh,

          Can I trigger the Throwable ex action from Byteman?

           

          That question doesn't really make any sense to me. Could you explain what it is that you want to achieve here?

           

          Do you a Byteman rule to be injected into the catch block for Throwable? If so then AT THROW is not going to work since that says inject the rule at a location where a throw occus and there is no throw operation at that point in the code. WHat you could do is use location AT INVOKE error(String, Exception). That say inject the rule at the firdt location in the method code where  a call is made to a method named error with signature (String, Exception).

           

          Of course, if there are other calls to log.error in other parts of the code then that location is ambiguous. So, you will need to tell Byteman which one you want. For example, if there was a also a call to log.error(e) in the catch block for SomeException then that wodlbe the first occurrence and the one you are interested would be the second occurrence. So, your rule would need to use  location AT INVOKE error(String, Exception) 2.

           

          regards,

           

           

          Andrew Dinn