PageRenderTime 11ms CodeModel.GetById 3ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/hudson-core/src/main/java/hudson/util/AdministrativeError.java

http://github.com/hudson/hudson
Java | 44 lines | 18 code | 5 blank | 21 comment | 0 complexity | 892ab8b3179cae54b09717d381645ee9 MD5 | raw file
 1package hudson.util;
 2
 3import hudson.model.AdministrativeMonitor;
 4import hudson.Extension;
 5
 6/**
 7 * A convenient {@link AdministrativeMonitor} implementations that show an error message
 8 * and optional stack trace. This is useful for notifying a non-fatal error to the administrator.
 9 *
10 * <p>
11 * These errors are registered when instances are created. No need to use {@link Extension}.
12 *
13 * @author Kohsuke Kawaguchi
14 */
15public class AdministrativeError extends AdministrativeMonitor {
16    public final String message;
17    public final String title;
18    public final Throwable details;
19
20    /**
21     * @param id
22     *      Unique ID that distinguishes this error from other errors.
23     *      Must remain the same across Hudson executions. Use a caller class name, or something like that.
24     * @param title
25     *      A title of the problem. This is used as the HTML title
26     *      of the details page. Should be just one sentence, like "ZFS migration error."
27     * @param message
28     *      A short description of the problem. This is used in the "/manage" page, and can include HTML, but it should be still short.
29     * @param details
30     *      An exception indicating the problem. The administrator can see this once they click "more details".
31     */
32    public AdministrativeError(String id, String title, String message, Throwable details) {
33        super(id);
34        this.message = message;
35        this.title = title;
36        this.details = details;
37
38        all().add(this);
39    }
40
41    public boolean isActivated() {
42        return true;
43    }
44}