org.jdesktop.swingx.error.ErrorInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swingx-all Show documentation
Show all versions of swingx-all Show documentation
A Maven project to aggregate all modules into a single artifact.
The newest version!
/*
* $Id: ErrorInfo.java 4170 2012-02-21 14:27:15Z kleopatra $
*
* Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
* Santa Clara, California 95054, U.S.A. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.jdesktop.swingx.error;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import javax.swing.SwingUtilities;
/**
* A simple class that encapsulates all the information needed
* to report a problem using the automated report/processing system.
*
* All HTML referred to in this API refers to version 3.2 of the HTML
* markup specification.
*
* @status REVIEWED
* @author Alexander Zuev
* @author rbair
*/
public class ErrorInfo {
/**
* Short string that will be used as a error title
*/
private String title;
/**
* Basic message that describes incident
*/
private String basicErrorMessage;
/**
* Message that will fully describe the incident with all the
* available details
*/
private String detailedErrorMessage;
/**
* A category name, indicating where in the application this incident
* occurred. It is recommended that this be the same value as you
* would use when logging.
*/
private String category;
/**
* Optional Throwable that will be used as a possible source for
* additional information
*/
private Throwable errorException;
/**
* Used to specify how bad this error was.
*/
private Level errorLevel;
/**
* A Map which captures the state of the application
* at the time of an exception. This state is then available for error
* reports.
*/
private Map state;
/**
* Creates a new ErrorInfo based on the provided data.
*
* @param title used as a quick reference for the
* error (for example, it might be used as the
* title of an error dialog or as the subject of
* an email message). May be null.
*
* @param basicErrorMessage short description of the problem. May be null.
*
* @param detailedErrorMessage full description of the problem. It is recommended,
* though not required, that this String contain HTML
* to improve the look and layout of the detailed
* error message. May be null.
*
* @param category A category name, indicating where in the application
* this incident occurred. It is recommended that
* this be the same value as you would use when logging.
* May be null.
*
* @param errorException Throwable
that can be used as a
* source for additional information such as call
* stack, thread name, etc. May be null.
*
* @param errorLevel any Level (Level.SEVERE, Level.WARNING, etc).
* If null, then the level will be set to SEVERE.
*
* @param state the state of the application at the time the incident occured.
* The standard System properties are automatically added to this
* state, and thus do not need to be included. This value may be null.
* If null, the resulting map will contain only the System properties.
* If there is a value in the map with a key that also occurs in the
* System properties (for example: sun.java2d.noddraw), then the
* developer supplied value will be used. In other words, defined
* parameters override standard ones. In addition, the keys
* "System.currentTimeMillis" and "isOnEDT" are both defined
* automatically.
*/
public ErrorInfo(String title, String basicErrorMessage, String detailedErrorMessage,
String category, Throwable errorException, Level errorLevel, Map state) {
this.title = title;
this.basicErrorMessage = basicErrorMessage;
this.detailedErrorMessage = detailedErrorMessage;
this.category = category;
this.errorException = errorException;
this.errorLevel = errorLevel == null ? Level.SEVERE : errorLevel;
this.state = new HashMap();
//first add all the System properties
try {
//NOTE: This is not thread safe because System.getProperties() does not appear
//to create a copy of the map. Thus, another thread could be modifying the System
//properties and the "state" at the time of this exception may not be
//accurate!
Properties props = System.getProperties();
for (Map.Entry