com.newrelic.weave.weavepackage.ErrorTrapHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of newrelic-weaver Show documentation
Show all versions of newrelic-weaver Show documentation
The Weaver of the Java agent.
/*
*
* * 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:
*
*
* - Think really hard about what you're about to do.
* - Create a class which directly extends this class and implements its own static method with the same
* signature as {@link ErrorTrapHandler#onWeaverThrow(Throwable t)}
* - Convert the implementing class into a {@link ClassNode} and configure it in {@link WeavePackageConfig}
*
*
* 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