protected void handleAndRaise(String suffix, Exception e) throws UserException { String message = e.getMessage(); int columnNr = -1; if (e instanceof JsonParseException) { final JsonParseException ex = (JsonParseException) e; message = ex.getOriginalMessage(); columnNr = ex.getLocation().getColumnNr(); } UserException.Builder exceptionBuilder = UserException.dataReadError(e) .message("%s - %s", suffix, message); if (columnNr > 0) { exceptionBuilder.pushContext("Column ", columnNr); } if (hadoopPath != null) { exceptionBuilder.pushContext("Record ", currentRecordNumberInFile()) .pushContext("File ", hadoopPath.toUri().getPath()); } throw exceptionBuilder.build(logger); }
@Override public UserException.Builder getExceptionWithContext(UserException.Builder exceptionBuilder, String field, String msg, Object... args) { if (msg != null) { exceptionBuilder.message(msg, args); } if(field != null) { exceptionBuilder.pushContext("Field ", field); } exceptionBuilder.pushContext("Column ", parser.getCurrentLocation().getColumnNr()+1) .pushContext("Line ", parser.getCurrentLocation().getLineNr()); return exceptionBuilder; }