All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.newrelic.weave.weavepackage.ErrorTrapHandler Maven / Gradle / Ivy

There is a newer version: 8.17.0
Show newest version
/*
 *
 *  * Copyright 2020 New Relic Corporation. All rights reserved.
 *  * SPDX-License-Identifier: Apache-2.0
 *
 */

package com.newrelic.weave.weavepackage;

import org.objectweb.asm.tree.ClassNode;

import com.newrelic.weave.utils.SynchronizedClassNode;
import com.newrelic.weave.utils.WeaveUtils;

/**
 * Supertype for all error trap handlers.
 * 
 * To create a new error trap you must:
 * 
 * 
    *
  1. Think really hard about what you're about to do.
  2. *
  3. Create a class which directly extends this class and implements its own static method with the same * signature as {@link ErrorTrapHandler#onWeaverThrow(Throwable t)}
  4. *
  5. Convert the implementing class into a {@link ClassNode} and configure it in {@link WeavePackageConfig}
  6. *
* * The code in onWeaverThrow will be inlined into every target class you're weaving into. This means this code * should not do anything stateful or attempt to load classes which will not be visible on all classloaders. */ public abstract class ErrorTrapHandler { public static final String HANDLER_METHOD_NAME = "onWeaverThrow"; public static final String HANDLER_METHOD_DESC = "(Ljava/lang/Throwable;)V"; /** * Using this handler will skip error trapping. This is the default handler. */ public static final ClassNode NO_ERROR_TRAP_HANDLER = new SynchronizedClassNode(WeaveUtils.ASM_API_LEVEL) { }; /** * This method will be inlined as an exception handler for when weave code throws an exception. This will not * handle original code throwing an exception or weave code explicitly calling throw. *

* * If you do not throw an exception here, the original return value will be returned in the composite code. * * @param weaverError the error that was thrown by the weaved code * @throws Throwable */ public static void onWeaverThrow(Throwable weaverError) throws Throwable { } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy