001 // License: GPL. For details, see LICENSE file. 002 package org.openstreetmap.josm.io; 003 004 /** 005 * Exception thrown when a communication error with the OSM server occurs. 006 */ 007 public class OsmTransferException extends Exception { 008 009 private String url = OsmApi.getOsmApi().getBaseUrl(); 010 011 /** 012 * Constructs an {@code OsmTransferException} with {@code null} as its error detail message. 013 * The cause is not initialized, and may subsequently be initialized by a call to {@link #initCause}. 014 */ 015 public OsmTransferException() { 016 } 017 018 /** 019 * Constructs an {@code OsmTransferException} with the specified detail message. 020 * The cause is not initialized, and may subsequently be initialized by a call to {@link #initCause}. 021 * 022 * @param message The detail message (which is saved for later retrieval by the {@link #getMessage} method) 023 */ 024 public OsmTransferException(String message) { 025 super(message); 026 } 027 028 /** 029 * Constructs an {@code OsmTransferException} with the specified cause and a detail message of 030 * <tt>(cause==null ? null : cause.toString())</tt> 031 * (which typically contains the class and detail message of <tt>cause</tt>). 032 * 033 * @param cause the cause (which is saved for later retrieval by the {@link #getCause} method). 034 * A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown. 035 */ 036 public OsmTransferException(Throwable cause) { 037 super(cause); 038 } 039 040 /** 041 * Constructs an {@code OsmTransferException} with the specified detail message and cause. 042 * 043 * <p> Note that the detail message associated with {@code cause} is <i>not</i> automatically incorporated 044 * into this exception's detail message. 045 * 046 * @param message The detail message (which is saved for later retrieval by the {@link #getMessage} method) 047 * @param cause The cause (which is saved for later retrieval by the {@link #getCause} method). 048 * A null value is permitted, and indicates that the cause is nonexistent or unknown. 049 * 050 */ 051 public OsmTransferException(String message, Throwable cause) { 052 super(message, cause); 053 } 054 055 /** 056 * Sets the URL related to this error. 057 * @param url the URL related to this error (which is saved for later retrieval by the {@link #getUrl} method). 058 */ 059 public void setUrl(String url) { 060 this.url = url; 061 } 062 063 /** 064 * Gets the URL related to this error. 065 * @return API base URL or URL set using the {@link #setUrl} method 066 */ 067 public String getUrl() { 068 return url; 069 } 070 }