PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/orc/error/compiletime/CompilationException.java

https://github.com/laurenyew/cOrcS
Java | 63 lines | 34 code | 8 blank | 21 comment | 18 complexity | db57c5a81fca0e2da45e38fff5f4e4e1 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. //
  2. // CompilationException.java -- Java class CompilationException
  3. // Project OrcScala
  4. //
  5. // $Id: CompilationException.java 2021 2010-08-12 22:44:02Z jthywissen $
  6. //
  7. // Copyright (c) 2010 The University of Texas at Austin. All rights reserved.
  8. //
  9. // Use and redistribution of this file is governed by the license terms in
  10. // the LICENSE file found in the project's top-level directory and also found at
  11. // URL: http://orc.csres.utexas.edu/license.shtml .
  12. //
  13. package orc.error.compiletime;
  14. import scala.util.parsing.input.NoPosition$;
  15. import orc.error.OrcException;
  16. import orc.error.compiletime.CompileLogger.Severity;
  17. /**
  18. * Exceptions generated during Orc compilation from source to
  19. * portable compiled representations.
  20. *
  21. * @author dkitchin
  22. */
  23. @SuppressWarnings("serial") //We don't care about serialization compatibility of Orc Exceptions
  24. public abstract class CompilationException extends OrcException {
  25. public CompilationException(final String message) {
  26. super(message);
  27. }
  28. public CompilationException(final String message, final Throwable cause) {
  29. super(message, cause);
  30. }
  31. public CompilationException(final Throwable cause) {
  32. super(cause);
  33. }
  34. public Severity severity() {
  35. if (this instanceof SeverityInternal) return Severity.INTERNAL;
  36. else if (this instanceof SeverityFatal) return Severity.FATAL;
  37. else if (this instanceof SeverityError) return Severity.ERROR;
  38. else if (this instanceof SeverityWarning) return Severity.WARNING;
  39. else if (this instanceof SeverityNotice) return Severity.NOTICE;
  40. else if (this instanceof SeverityInfo) return Severity.INFO;
  41. else if (this instanceof SeverityDebug) return Severity.DEBUG;
  42. else return Severity.UNKNOWN;
  43. }
  44. /**
  45. * @return "position: detailMessage (newline) position.longString"
  46. */
  47. @Override
  48. public String getMessageAndPositon() {
  49. if (getPosition() != null && !(getPosition() instanceof NoPosition$)) {
  50. return getPosition().toString() + ": " + getLocalizedMessage() + "\n" + getPosition().longString();
  51. } else {
  52. return getLocalizedMessage();
  53. }
  54. }
  55. }