You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BCException.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. import java.io.PrintStream;
  14. import java.io.PrintWriter;
  15. import org.aspectj.bridge.context.CompilationAndWeavingContext;
  16. /**
  17. * Exception to use inside the bcweaver.
  18. */
  19. @SuppressWarnings("serial")
  20. public class BCException extends RuntimeException {
  21. Throwable thrown;
  22. public BCException() {
  23. super();
  24. }
  25. public BCException(String s) {
  26. super(s + "\n" + CompilationAndWeavingContext.getCurrentContext());
  27. }
  28. public BCException(String s, Throwable thrown) {
  29. this(s);
  30. this.thrown = thrown;
  31. }
  32. public void printStackTrace() {
  33. printStackTrace(System.err);
  34. }
  35. public void printStackTrace(PrintStream s) {
  36. printStackTrace(new PrintWriter(s));
  37. }
  38. public void printStackTrace(PrintWriter s) {
  39. super.printStackTrace(s);
  40. if (null != thrown) {
  41. s.print("Caused by: ");
  42. s.print(thrown.getClass().getName());
  43. String message = thrown.getMessage();
  44. if (null != message) {
  45. s.print(": ");
  46. s.print(message);
  47. }
  48. s.println();
  49. thrown.printStackTrace(s);
  50. }
  51. }
  52. }