001/*
002 * Copyright 2002-2013 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.web.socket.sockjs;
018
019import java.util.List;
020
021/**
022 * An exception thrown when a message frame was successfully received over an HTTP POST
023 * and parsed but one or more of the messages it contained could not be delivered to the
024 * WebSocketHandler either because the handler failed or because the connection got
025 * closed.
026 *
027 * <p>The SockJS session is not automatically closed after this exception.
028 *
029 * @author Rossen Stoyanchev
030 * @since 4.0
031 */
032@SuppressWarnings("serial")
033public class SockJsMessageDeliveryException extends SockJsException {
034
035        private final List<String> undeliveredMessages;
036
037
038        public SockJsMessageDeliveryException(String sessionId, List<String> undeliveredMessages, Throwable cause) {
039                super("Failed to deliver message(s) " + undeliveredMessages + " for session " + sessionId, sessionId, cause);
040                this.undeliveredMessages = undeliveredMessages;
041        }
042
043        public SockJsMessageDeliveryException(String sessionId, List<String> undeliveredMessages, String message) {
044                super("Failed to deliver message(s) " + undeliveredMessages + " for session "
045                                + sessionId + ": " + message, sessionId, null);
046                this.undeliveredMessages = undeliveredMessages;
047        }
048
049        public List<String> getUndeliveredMessages() {
050                return this.undeliveredMessages;
051        }
052
053}