1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
  23 
  24 import com.sun.org.apache.xalan.internal.xsltc.compiler.SyntaxTreeNode;
  25 
  26 /**
  27  * @author Jacek Ambroziak
  28  * @author Santiago Pericas-Geertsen
  29  */
  30 public class TypeCheckError extends Exception {
  31     static final long serialVersionUID = 3246224233917854640L;
  32     ErrorMsg _error = null;
  33     SyntaxTreeNode _node = null;
  34 
  35     public TypeCheckError(SyntaxTreeNode node) {
  36         super();
  37         _node = node;
  38     }
  39 
  40     public TypeCheckError(ErrorMsg error) {
  41         super();
  42         _error = error;
  43     }
  44 
  45     public TypeCheckError(String code, Object param) {
  46         super();
  47         _error = new ErrorMsg(code, param);
  48     }
  49 
  50     public TypeCheckError(String code, Object param1, Object param2) {
  51         super();
  52         _error = new ErrorMsg(code, param1, param2);
  53     }
  54 
  55     public ErrorMsg getErrorMsg() {
  56         return _error;
  57     }
  58 
  59     public String getMessage() {
  60         return toString();
  61     }
  62 
  63     public String toString() {
  64         String result;
  65 
  66         if (_error == null) {
  67             if (_node != null) {
  68                 _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_ERR,
  69                                       _node.toString());
  70             } else {
  71                 _error = new ErrorMsg(ErrorMsg.TYPE_CHECK_UNK_LOC_ERR);
  72             }
  73         }
  74 
  75         return _error.toString();
  76     }
  77 }