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

io.honeybadger.reporter.HoneybadgerCLI Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package io.honeybadger.reporter;

import io.honeybadger.reporter.config.StandardConfigContext;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Simple CLI utility that will allow you to post an error message to
 * Honeybadger.
 *
 * @author Elijah Zupancic
 * @since 1.0.0
 */
public final class HoneybadgerCLI {
    private HoneybadgerCLI() { }

    @SuppressWarnings("DefaultCharset")
    public static void main(final String[] argv) {
        Scanner in = new Scanner(System.in);

        System.out.print("What is your Honeybadger API key: ");

        StandardConfigContext config = new StandardConfigContext();
        config.setApiKey(in.nextLine());
        System.out.print("\n");

        System.out.print("What message do you want to send: ");
        String message = in.nextLine();

        RuntimeException exception = new RuntimeException(message);
        NoticeReporter reporter = new HoneybadgerReporter(config);
        reporter.reportError(exception);

        io.honeybadger.reporter.dto.Context context = new io.honeybadger.reporter.dto.Context();
        context.put("context1", "data1");
        context.setUsername("bob");
        io.honeybadger.reporter.dto.Request request = new io.honeybadger.reporter.dto.Request(context, null, null, null, null);

        List tags = new ArrayList();
        tags.add("asdf");
        tags.add("baoo");
        reporter.reportError(exception, request, "asefsfa", tags);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy