1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*
  17. * $Id: TypeCheckError.java,v 1.7 2004/02/16 22:26:44 minchau Exp $
  18. */
  19. package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
  20. import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode;
  21. /**
  22. * @author Jacek Ambroziak
  23. * @author Santiago Pericas-Geertsen
  24. */
  25. public class TypeCheckError extends Exception {
  26. ErrorMsg _error = null;
  27. SyntaxTreeNode _node = null;
  28. public TypeCheckError(SyntaxTreeNode node) {
  29. super();
  30. _node = node;
  31. }
  32. public TypeCheckError(ErrorMsg error) {
  33. super();
  34. _error = error;
  35. }
  36. public TypeCheckError(String code, Object param) {
  37. super();
  38. _error = new ErrorMsg(code, param);
  39. }
  40. public TypeCheckError(String code, Object param1, Object param2) {
  41. super();
  42. _error = new ErrorMsg(code, param1, param2);
  43. }
  44. public ErrorMsg getErrorMsg() {
  45. return _error;
  46. }
  47. public String getMessage() {
  48. return toString();
  49. }
  50. public String toString() {
  51. String result;
  52. if (_error == null) {
  53. if (_node != null) {
  54. _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_ERR,
  55. _node.toString());
  56. } else {
  57. _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_UNK_LOC_ERR);
  58. }
  59. }
  60. return _error.toString();
  61. }
  62. }