001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.hadoop.mapred;
019
020 import java.io.IOException;
021 import java.util.List;
022 import java.util.Iterator;
023
024 import org.apache.hadoop.classification.InterfaceAudience;
025 import org.apache.hadoop.classification.InterfaceStability;
026
027 /**
028 * This class wraps a list of problems with the input, so that the user
029 * can get a list of problems together instead of finding and fixing them one
030 * by one.
031 */
032 @InterfaceAudience.Public
033 @InterfaceStability.Stable
034 public class InvalidInputException extends IOException {
035
036 private static final long serialVersionUID = 1L;
037 private List<IOException> problems;
038
039 /**
040 * Create the exception with the given list.
041 * @param probs the list of problems to report. this list is not copied.
042 */
043 public InvalidInputException(List<IOException> probs) {
044 problems = probs;
045 }
046
047 /**
048 * Get the complete list of the problems reported.
049 * @return the list of problems, which must not be modified
050 */
051 public List<IOException> getProblems() {
052 return problems;
053 }
054
055 /**
056 * Get a summary message of the problems found.
057 * @return the concatenated messages from all of the problems.
058 */
059 public String getMessage() {
060 StringBuffer result = new StringBuffer();
061 Iterator<IOException> itr = problems.iterator();
062 while(itr.hasNext()) {
063 result.append(itr.next().getMessage());
064 if (itr.hasNext()) {
065 result.append("\n");
066 }
067 }
068 return result.toString();
069 }
070 }