All exceptions from Java apps are automatically captured by Atatus. If you wish to send exceptions manually, you can do so by using the captureException(ex) method.

Add dependency before starting with the api.

pom.xml

<dependency>
    <groupId>com.atatus.apm</groupId>
    <artifactId>atatus-agent-api</artifactId>
    <version>2.0.0</version>
</dependency>

Compatibility

Compatible with all Java agent versions.

Syntax

copy
icon/buttons/copy
transaction.captureException(ex);

Parameter

Parameter Type Description
ex Exception (Required) Custom Exception instance.

Examples

copy
icon/buttons/copy
import com.atatus.apm.api.Atatus;

public class ViewController {

    public String unsafeMethod() {

        try {
            // code here
        } catch (Exception ex) {
            // This sends an exception event to Atatus
            Atatus.captureException(ex);
            throw ex;
        }
    }
}
import com.atatus.apm.api.Atatus;
import com.atatus.apm.api.Transaction;

Transaction transaction = Atatus.currentTransaction();
transaction.captureException(new Exception("Incorrect filename!"));

// OR

Atatus.captureException(new Exception("Incorrect filename!"));