001/* 002 * Copyright 2002-2014 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 */ 016 017package org.springframework.messaging.support; 018 019import java.util.Map; 020 021import org.springframework.messaging.MessageHeaders; 022 023/** 024 * A {@link GenericMessage} with a {@link Throwable} payload. 025 * 026 * @author Mark Fisher 027 * @author Oleg Zhurakousky 028 * @since 4.0 029 * @see MessageBuilder 030 */ 031public class ErrorMessage extends GenericMessage<Throwable> { 032 033 private static final long serialVersionUID = -5470210965279837728L; 034 035 036 /** 037 * Create a new message with the given payload. 038 * @param payload the message payload (never {@code null}) 039 */ 040 public ErrorMessage(Throwable payload) { 041 super(payload); 042 } 043 044 /** 045 * Create a new message with the given payload and headers. 046 * The content of the given header map is copied. 047 * @param payload the message payload (never {@code null}) 048 * @param headers message headers to use for initialization 049 */ 050 public ErrorMessage(Throwable payload, Map<String, Object> headers) { 051 super(payload, headers); 052 } 053 054 /** 055 * A constructor with the {@link MessageHeaders} instance to use. 056 * <p><strong>Note:</strong> the given {@code MessageHeaders} instance 057 * is used directly in the new message, i.e. it is not copied. 058 * @param payload the message payload (never {@code null}) 059 * @param headers message headers 060 */ 061 public ErrorMessage(Throwable payload, MessageHeaders headers) { 062 super(payload, headers); 063 } 064 065}