/** Prints the exception to the log file and (possibly) notifies the user. * Guesses at the severity. * @param t the exception to notify * @see #UNKNOWN * @see #notify(int, Throwable) */ public final void notify(Throwable t) { notify(UNKNOWN, t); }
/** Annotates given exception with given values. All the * previous annotations are kept and this new is added at * the top of the annotation stack (index 0 of the annotation * array). * * @param t the exception * @param localizedMessage localized message for the user or null * @return the same exception <code>t</code> (as a convenience) */ public final Throwable annotate(Throwable t, String localizedMessage) { return annotate(t, UNKNOWN, null, localizedMessage, null, null); }
/** Get the name of the service type. * The default value is given by {@link #displayName}. * @return a human-presentable name for the service type */ public String getName() { return (name == null) ? displayName() : name; }
/** Updates the delegates.*/ public void resultChanged(LookupEvent ev) { if (r != null) { setDelegates(r.allInstances()); } }
/** Logs the message to log file and (possibly) tells the user. * Uses a default severity. * @param s the log message */ public final void log(String s) { // not yet: after phase III: * @deprecated {@link Logger#log} log(INFORMATIONAL, s); }
/** * Takes all our delegates, asks them for an instance identified by * name and adds those results as new delegates for dem. * @param String name * @param DelagatingErrorManager d the instance to which we will attach */ private void attachNewDelegates(DelegatingErrorManager dem, String name) { Set<ErrorManager> newDelegatesForDem = new HashSet<ErrorManager>(); for (ErrorManager e : delegates) { newDelegatesForDem.add(e.getInstance(name)); } dem.setDelegates(newDelegatesForDem); }
/** Calls all delegates. */ public boolean isLoggable(int severity) { if (severity == UNKNOWN) { throw new IllegalArgumentException("ErrorManager.isLoggable(UNKNOWN) is not permitted"); // NOI18N } if (delegates.isEmpty()) { return logger().isLoggable(convertSeverity(severity, false, null)); } for (ErrorManager em : delegates) { if (em.isLoggable(severity)) { return true; } } return false; }
/** Get all available services that are assignable to the given superclass. * @param clazz the class that all services should be subclass of * @return an enumeration of all matching {@link ServiceType}s */ public <T extends ServiceType> Enumeration<T> services(final Class<T> clazz) { class IsInstance implements Enumerations.Processor<ServiceType,T> { public T process(ServiceType obj, Collection ignore) { return clazz.isInstance(obj) ? clazz.cast(obj) : null; } } return Enumerations.filter(services(), new IsInstance()); }
/** Exit NetBeans with the given exit code. * This method will return only if {@link java.lang.System#exit} fails, or if at least one component of the * system refuses to exit (because it cannot be properly shut down). The * default implementation calls {@link #exit()} for compatibility reasons, * but subclasses are encouraged to provide better implementation. * * @param status the exit code of the application * @since 8.23 */ public void exit(int status) { exit(); }
/** Calls all delegates. */ public boolean isNotifiable(int severity) { if (severity == UNKNOWN) { throw new IllegalArgumentException("ErrorManager.isNotifiable(UNKNOWN) is not permitted"); // NOI18N } if (delegates.isEmpty()) { return logger().isLoggable(convertSeverity(severity, true, null)); } for (ErrorManager em : delegates) { if (em.isNotifiable(severity)) { return true; } } return false; }
/** * Test whether a throwable, if {@link #notify(int, Throwable) notified} at the given * level, will actually be displayed in any way (even to a log file etc.). * If not, there is no point in constructing it. * <p>This method is distinct from {@link #isLoggable} because an error manager * implementation may choose to notify stack traces at a level where it would * not log messages. See issue #24056 for justification. * <p>The default implementation just calls {@link #isLoggable}. Subclasses * should override to be more precise - <strong>treat this method as abstract</strong>. * @param severity a notification severity * @return true if a throwable notified at this severity will be used; false if it will be ignored * @since 3.18 */ public boolean isNotifiable(int severity) { return isLoggable(severity); }
/** * Updates the list of delegates. Also updates all instances created * by ourselves. */ public synchronized void setDelegates(Collection<? extends ErrorManager> newDelegates) { delegates = new LinkedHashSet<ErrorManager>(newDelegates); for (DelegatingErrorManager dem : createdByMe) { attachNewDelegates(dem, dem.getName()); } }
/** Calls all delegates. */ public Annotation[] findAnnotations(Throwable t) { for (ErrorManager em : delegates) { Annotation[] res = em.findAnnotations(t); if ((res != null) && (res.length > 0)) { return res; } } return new Annotation[0]; }
private static AnnException findOrCreate0(Throwable t, boolean create) { if (t instanceof AnnException) { return (AnnException) t; } if (t.getCause() == null) { if (create) { t.initCause(new AnnException()); } return (AnnException) t.getCause(); } return findOrCreate0(t.getCause(), create); }
/** Getter for the default version of error manager. * @return the error manager installed in the system * @since 2.1 */ public static ErrorManager getDefault() { synchronized (ErrorManager.class) { if (current != null) { return current; } } return getDefaultDelegate(); }
/** Calls all delegates. */ public Throwable attachAnnotations(Throwable t, Annotation[] arr) { for (ErrorManager em : delegates) { em.attachAnnotations(t, arr); } return t; }
public void printStackTrace(PrintWriter s) { super.printStackTrace(s); logRecords(s); }
public void printStackTrace() { printStackTrace(System.err); }
/** Annotates target exception with given exception. All the * previous annotations are kept and this new is added at * the top of the annotation stack (index 0 of the annotation * array). * <p>Consider using {@link Throwable#initCause} instead; this * will be correctly reported by the NetBeans error manager, and * also works properly with {@link Throwable#printStackTrace()}. * @param target the exception to be annotated * @param t the exception that will be added * @return the same exception <code>target</code> (as a convenience) */ public final Throwable annotate(Throwable target, Throwable t) { return annotate(target, UNKNOWN, null, null, t, null); }
public void printStackTrace(PrintStream s) { super.printStackTrace(s); logRecords(s); }