Back to index

apport  2.4
Public Member Functions | Static Public Member Functions
com.ubuntu.apport.ApportUncaughtExceptionHandler Class Reference

List of all members.

Public Member Functions

void uncaughtException (Thread t, Throwable e)
HashMap getProblemReport (Thread t, Throwable e)
void writeProblemReport (OutputStream os, HashMap pr) throws IOException

Static Public Member Functions

static String mainClassUrl (Throwable e)
static void install ()

Detailed Description

Definition at line 19 of file ApportUncaughtExceptionHandler.java.


Member Function Documentation

HashMap com.ubuntu.apport.ApportUncaughtExceptionHandler.getProblemReport ( Thread  t,
Throwable  e 
) [inline]

Definition at line 60 of file ApportUncaughtExceptionHandler.java.

                                                              {
              HashMap problemReport = new HashMap();
              
              StringWriter sw = new StringWriter();
              PrintWriter pw = new PrintWriter(sw);
              e.printStackTrace(pw);
              problemReport.put("StackTrace", sw.toString());

              problemReport.put("MainClassUrl", mainClassUrl(e));

              return problemReport;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 105 of file ApportUncaughtExceptionHandler.java.

                                    {
              Thread.setDefaultUncaughtExceptionHandler(new ApportUncaughtExceptionHandler());
       }
static String com.ubuntu.apport.ApportUncaughtExceptionHandler.mainClassUrl ( Throwable  e) [inline, static]

Definition at line 88 of file ApportUncaughtExceptionHandler.java.

                                                      {
              StackTraceElement[] stacktrace = e.getStackTrace();
              String className = stacktrace[stacktrace.length-1].getClassName();

              if (!className.startsWith("/")) {
                     className = "/" + className;
              }
              className = className.replace('.', '/');
              className = className + ".class";

              java.net.URL classUrl =
                     new ApportUncaughtExceptionHandler().getClass().getResource(className);

              return classUrl.toString();
    }

Here is the caller graph for this function:

void com.ubuntu.apport.ApportUncaughtExceptionHandler.uncaughtException ( Thread  t,
Throwable  e 
) [inline]

Definition at line 24 of file ApportUncaughtExceptionHandler.java.

                                                            {
              //System.out.println("uncaughtException");
              if (e instanceof ThreadDeath)
                     return;

              HashMap problemReport = getProblemReport(t, e);
              //System.out.println("got problem report");

              try {
                     String handler_path = System.getenv("APPORT_JAVA_EXCEPTION_HANDLER");
                     if (handler_path == null)
                         handler_path = "/usr/share/apport/java_uncaught_exception";
                     Process p = new ProcessBuilder(handler_path).start();
                     //System.out.println("started process");

                     OutputStream os = p.getOutputStream();
                     writeProblemReport(os, problemReport);
                     //System.out.println("wrote problem report");

                     os.close();

                     try {
                            p.waitFor();
                     } catch (InterruptedException ignore) {
                            // ignored
                     }

              } catch (java.io.IOException ioe) {
                  System.out.println("could not call java_uncaught_exception");
              }

        System.err.print("Exception in thread \""
                         + t.getName() + "\" ");
        e.printStackTrace(System.err);
       }

Here is the call graph for this function:

void com.ubuntu.apport.ApportUncaughtExceptionHandler.writeProblemReport ( OutputStream  os,
HashMap  pr 
) throws IOException [inline]

Definition at line 73 of file ApportUncaughtExceptionHandler.java.

                                 {

              StringWriter sw = new StringWriter();
              for(Object o : pr.keySet()) {
                     String key = (String)o;
                     String value = (String)pr.get(o);
                     sw.write(key);
                     sw.write("\0");
                     sw.write(value);
                     sw.write("\0");
              }
              os.write(sw.toString().getBytes());
       }

Here is the caller graph for this function:


The documentation for this class was generated from the following file: