Package org.openstreetmap.josm.io
Class OsmApiException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- org.openstreetmap.josm.io.OsmTransferException
-
- org.openstreetmap.josm.io.OsmApiException
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
OsmApiPrimitiveGoneException
public class OsmApiException extends OsmTransferException
Exception thrown when a communication error occurs when accessing the OSM API.- See Also:
OsmApi
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
accessedUrl
private java.lang.String
contentType
private java.lang.String
errorBody
private java.lang.String
errorHeader
private java.lang.String
login
private int
responseCode
-
Constructor Summary
Constructors Constructor Description OsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody)
Constructs anOsmApiException
with the specified response code, error header and error bodyOsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody, java.lang.String accessedUrl)
Constructs anOsmApiException
with the specified response code, error header and error bodyOsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody, java.lang.String accessedUrl, java.lang.String login)
Constructs anOsmApiException
with the specified response code, error header and error bodyOsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody, java.lang.String accessedUrl, java.lang.String login, java.lang.String contentType)
Constructs anOsmApiException
with the specified response code, error header and error bodyOsmApiException(java.lang.String message)
Constructs anOsmApiException
with the specified detail message.OsmApiException(java.lang.String message, java.lang.Throwable cause)
Constructs anOsmApiException
with the specified detail message and cause.OsmApiException(java.lang.Throwable cause)
Constructs anOsmApiException
with the specified cause and a detail message of(cause==null ? null : cause.toString())
(which typically contains the class and detail message ofcause
).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkHtmlBody()
java.lang.String
getAccessedUrl()
Replies the complete URL accessed when this error occurred.java.lang.String
getContentType()
Replies the response content-type.java.lang.String
getDisplayMessage()
Replies a message suitable to be displayed in a message dialogjava.lang.String
getErrorBody()
Replies the error body.java.lang.String
getErrorHeader()
Replies the error header.java.lang.String
getLogin()
Replies the login used to connect to OSM API.java.lang.String
getMessage()
int
getResponseCode()
Replies the HTTP response code.boolean
isHtml()
Determines if the exception hastext/html
as content type.void
setAccessedUrl(java.lang.String url)
Sets the complete URL accessed when this error occurred.void
setContentType(java.lang.String contentType)
Sets the response content-type.void
setErrorBody(java.lang.String errorBody)
Sets the error body.void
setErrorHeader(java.lang.String errorHeader)
Sets the error header.void
setLogin(java.lang.String login)
Sets the login used to connect to OSM API.void
setResponseCode(int responseCode)
Sets the HTTP response code.-
Methods inherited from class org.openstreetmap.josm.io.OsmTransferException
getUrl, setUrl
-
-
-
-
Field Detail
-
responseCode
private int responseCode
-
contentType
private java.lang.String contentType
-
errorHeader
private java.lang.String errorHeader
-
errorBody
private java.lang.String errorBody
-
accessedUrl
private java.lang.String accessedUrl
-
login
private java.lang.String login
-
-
Constructor Detail
-
OsmApiException
public OsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody, java.lang.String accessedUrl, java.lang.String login, java.lang.String contentType)
Constructs anOsmApiException
with the specified response code, error header and error body- Parameters:
responseCode
- The HTTP response code replied by the OSM server. SeeHttpURLConnection
for predefined HTTP response code valueserrorHeader
- The error header, as transmitted in theError
field of the HTTP response headererrorBody
- The error body, as transmitted in the HTTP response bodyaccessedUrl
- The complete URL accessed when this error occurredlogin
- the login used to connect to OSM API (can be null)contentType
- the response content-type- Since:
- 13499
-
OsmApiException
public OsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody, java.lang.String accessedUrl, java.lang.String login)
Constructs anOsmApiException
with the specified response code, error header and error body- Parameters:
responseCode
- The HTTP response code replied by the OSM server. SeeHttpURLConnection
for predefined HTTP response code valueserrorHeader
- The error header, as transmitted in theError
field of the HTTP response headererrorBody
- The error body, as transmitted in the HTTP response bodyaccessedUrl
- The complete URL accessed when this error occurredlogin
- the login used to connect to OSM API (can be null)- Since:
- 12992
-
OsmApiException
public OsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody, java.lang.String accessedUrl)
Constructs anOsmApiException
with the specified response code, error header and error body- Parameters:
responseCode
- The HTTP response code replied by the OSM server. SeeHttpURLConnection
for predefined HTTP response code valueserrorHeader
- The error header, as transmitted in theError
field of the HTTP response headererrorBody
- The error body, as transmitted in the HTTP response bodyaccessedUrl
- The complete URL accessed when this error occurred- Since:
- 5584
-
OsmApiException
public OsmApiException(int responseCode, java.lang.String errorHeader, java.lang.String errorBody)
Constructs anOsmApiException
with the specified response code, error header and error body- Parameters:
responseCode
- The HTTP response code replied by the OSM server. SeeHttpURLConnection
for predefined HTTP response code valueserrorHeader
- The error header, as transmitted in theError
field of the HTTP response headererrorBody
- The error body, as transmitted in the HTTP response body
-
OsmApiException
public OsmApiException(java.lang.String message)
Constructs anOsmApiException
with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call toThrowable.initCause(java.lang.Throwable)
.- Parameters:
message
- The detail message (which is saved for later retrieval by thegetMessage()
method)
-
OsmApiException
public OsmApiException(java.lang.Throwable cause)
Constructs anOsmApiException
with the specified cause and a detail message of(cause==null ? null : cause.toString())
(which typically contains the class and detail message ofcause
).- Parameters:
cause
- the cause (which is saved for later retrieval by theThrowable.getCause()
method). Anull
value is permitted, and indicates that the cause is nonexistent or unknown.
-
OsmApiException
public OsmApiException(java.lang.String message, java.lang.Throwable cause)
Constructs anOsmApiException
with the specified detail message and cause.Note that the detail message associated with
cause
is not automatically incorporated into this exception's detail message.- Parameters:
message
- The detail message (which is saved for later retrieval by thegetMessage()
method)cause
- The cause (which is saved for later retrieval by theThrowable.getCause()
method). A null value is permitted, and indicates that the cause is nonexistent or unknown.
-
-
Method Detail
-
checkHtmlBody
private void checkHtmlBody()
-
getResponseCode
public int getResponseCode()
Replies the HTTP response code.- Returns:
- The HTTP response code replied by the OSM server. Refer to OSM API to see the list of response codes returned by the API for each call.
-
setResponseCode
public void setResponseCode(int responseCode)
Sets the HTTP response code.- Parameters:
responseCode
- The HTTP response code replied by the OSM server. SeeHttpURLConnection
for predefined HTTP response code values
-
getErrorHeader
public java.lang.String getErrorHeader()
Replies the error header.- Returns:
- the error header, as transmitted in the
Error
field of the HTTP response header
-
setErrorHeader
public void setErrorHeader(java.lang.String errorHeader)
Sets the error header.- Parameters:
errorHeader
- the error header, as transmitted in theError
field of the HTTP response header
-
getErrorBody
public java.lang.String getErrorBody()
Replies the error body.- Returns:
- The error body, as transmitted in the HTTP response body
-
setErrorBody
public void setErrorBody(java.lang.String errorBody)
Sets the error body.- Parameters:
errorBody
- The error body, as transmitted in the HTTP response body
-
getMessage
public java.lang.String getMessage()
- Overrides:
getMessage
in classjava.lang.Throwable
-
getDisplayMessage
public java.lang.String getDisplayMessage()
Replies a message suitable to be displayed in a message dialog- Returns:
- a message which is suitable to be displayed in a message dialog
-
setAccessedUrl
public void setAccessedUrl(java.lang.String url)
Sets the complete URL accessed when this error occurred. This is distinct from the one set withOsmTransferException.setUrl(java.lang.String)
, which is generally only the base URL of the server.- Parameters:
url
- the complete URL accessed when this error occurred.
-
getAccessedUrl
public java.lang.String getAccessedUrl()
Replies the complete URL accessed when this error occurred. This is distinct from the one returned byOsmTransferException.getUrl()
, which is generally only the base URL of the server.- Returns:
- the complete URL accessed when this error occurred.
-
setLogin
public void setLogin(java.lang.String login)
Sets the login used to connect to OSM API.- Parameters:
login
- the login used to connect to OSM API- Since:
- 12992
-
getLogin
public java.lang.String getLogin()
Replies the login used to connect to OSM API.- Returns:
- the login used to connect to OSM API, or
null
- Since:
- 12992
-
setContentType
public final void setContentType(java.lang.String contentType)
Sets the response content-type.- Parameters:
contentType
- the response content-type.- Since:
- 13499
-
getContentType
public final java.lang.String getContentType()
Replies the response content-type.- Returns:
- the response content-type
- Since:
- 13499
-
isHtml
public final boolean isHtml()
Determines if the exception hastext/html
as content type.- Returns:
true
if the exception hastext/html
as content type.- Since:
- 14810
-
-