001/* 002 * Copyright 2006-2010 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.batch.item.mail; 017 018import org.springframework.mail.MailException; 019import org.springframework.mail.MailMessage; 020 021/** 022 * This class is used to handle errors that occur when email messages are unable 023 * to be sent. 024 * 025 * @author Dan Garrette 026 * @author Dave Syer 027 * 028 * @since 2.1 029 */ 030public interface MailErrorHandler { 031 032 /** 033 * This method will be called for each message that failed sending in the 034 * chunk. If the failed message is needed by the handler it will need to be 035 * downcast according to its runtime type. If an exception is thrown from 036 * this method, then it will propagate to the caller. 037 * 038 * @param message the failed message 039 * @param exception the exception that caused the failure 040 * @throws MailException if the exception cannot be handled 041 */ 042 public void handle(MailMessage message, Exception exception) throws MailException; 043 044}