1 /* 2 * Copyright 2016 Andrew Rucker Jones. 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 package com.opencsv.exceptions; 17 18 import java.io.IOException; 19 20 /** 21 * Exception that is thrown when the {@link com.opencsv.CSVReader} cannot process a line. 22 */ 23 public class CsvMalformedLineException extends IOException { 24 private static final long serialVersionUID = 1L; 25 private long lineNumber; 26 private String context; 27 28 /** 29 * @return The row number set during construction of the exception 30 */ 31 public long getLineNumber() { 32 return lineNumber; 33 } 34 35 /** 36 * @return Context set during construction of the exception 37 */ 38 public String getContext() { 39 return context; 40 } 41 42 /** 43 * Nullary constructor. Does nothing. 44 */ 45 public CsvMalformedLineException() { 46 super(); 47 } 48 49 /** 50 * Constructor with a message. 51 * 52 * @param message A human-readable error message 53 * @param lineNumber Line number where error occurred 54 * @param context Line (or part of the line) that caused the error 55 */ 56 public CsvMalformedLineException(String message, long lineNumber, String context) { 57 super(message); 58 this.lineNumber = lineNumber; 59 this.context = context; 60 } 61 }