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.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 Common Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/cpl-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. public class BCException extends RuntimeException {
  20. Throwable thrown;
  21. public BCException() {
  22. super();
  23. }
  24. public BCException(String s) {
  25. super(s + "\n" + CompilationAndWeavingContext.getCurrentContext());
  26. }
  27. public BCException(String s, Throwable thrown) {
  28. this(s);
  29. this.thrown = thrown;
  30. }
  31. public void printStackTrace() {
  32. printStackTrace(System.err);
  33. }
  34. public void printStackTrace(PrintStream s) {
  35. printStackTrace(new PrintWriter(s));
  36. }
  37. public void printStackTrace(PrintWriter s) {
  38. super.printStackTrace(s);
  39. if (null != thrown) {
  40. s.print("Caused by: ");
  41. s.print(thrown.getClass().getName());
  42. String message = thrown.getMessage();
  43. if (null != message) {
  44. s.print(": ");
  45. s.print(message);
  46. }
  47. s.println();
  48. thrown.printStackTrace(s);
  49. }
  50. }
  51. }