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, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.reef.vortex.api; 020 021import org.apache.reef.annotations.Unstable; 022import org.apache.reef.annotations.audience.Private; 023 024import java.util.ArrayList; 025import java.util.Collections; 026import java.util.List; 027 028/** 029 * Exception thrown when an aggregate function fails. 030 * Call {@link Exception#getCause()} to find the cause of failure in aggregation. 031 * Call {@link VortexAggregateException#getInputs()} to get the inputs that correlate 032 * with the failure. 033 */ 034@Unstable 035public final class VortexAggregateException extends Exception { 036 private final List<Object> inputList; 037 038 @Private 039 public VortexAggregateException(final Throwable cause, final List<?> inputList) { 040 super(cause); 041 this.inputList = new ArrayList<>(inputList); 042 } 043 044 @Private 045 public VortexAggregateException(final String message, 046 final Throwable cause, 047 final List<?> inputList) { 048 super(message, cause); 049 this.inputList = new ArrayList<>(inputList); 050 } 051 052 /** 053 * @return Inputs that correlate with the aggregation failure. 054 */ 055 public List<Object> getInputs() { 056 return Collections.unmodifiableList(inputList); 057 } 058}