/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

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