001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.io.imagery; 003 004import java.net.URL; 005import java.util.Arrays; 006import java.util.Collection; 007 008import org.openstreetmap.josm.tools.Utils; 009 010/** 011 * WMS Service Exception, as defined by {@code application/vnd.ogc.se_xml} format:<ul> 012 * <li><a href="http://schemas.opengis.net/wms/1.1.0/exception_1_1_0.dtd">WMS 1.1.0 DTD</a></li> 013 * <li><a href="http://schemas.opengis.net/wms/1.3.0/exception_1_3_0.dtd">WMS 1.3.0 XSD</a></li> 014 * </ul> 015 * @since 7425 016 */ 017public class WMSException extends Exception { 018 019 private final WMSRequest request; 020 private final URL url; 021 private final String[] exceptions; 022 023 /** 024 * Constructs a new {@code WMSException}. 025 * @param request the WMS request that lead to this exception 026 * @param url the URL that lead to this exception 027 * @param exceptions the exceptions replied by WMS server 028 */ 029 public WMSException(WMSRequest request, URL url, Collection<String> exceptions) { 030 super(Utils.join("\n", exceptions)); 031 this.request = request; 032 this.url = url; 033 this.exceptions = exceptions.toArray(new String[0]); 034 } 035 036 /** 037 * Replies the WMS request that lead to this exception. 038 * @return the WMS request 039 */ 040 public final WMSRequest getRequest() { 041 return request; 042 } 043 044 /** 045 * Replies the URL that lead to this exception. 046 * @return the URL 047 */ 048 public final URL getUrl() { 049 return url; 050 } 051 052 /** 053 * Replies the WMS Service exceptions. 054 * @return the exceptions 055 */ 056 public final Collection<String> getExceptions() { 057 return Arrays.asList(exceptions); 058 } 059}