org.openstreetmap.josm.tools
Class ExceptionUtil

java.lang.Object
  extended by org.openstreetmap.josm.tools.ExceptionUtil

public class ExceptionUtil
extends java.lang.Object


Constructor Summary
private ExceptionUtil()
           
 
Method Summary
static java.lang.String escapeReservedCharactersHTML(java.lang.String s)
          Replaces some HTML reserved characters (<, > and &) by their equivalent entity (<, > and &);
static java.lang.String explainBadRequest(OsmApiException e)
          Explains a OsmApiException which was thrown because of a bad request
static java.lang.String explainBandwidthLimitExceeded(OsmApiException e)
          Explains a OsmApiException which was thrown because of bandwidth limit exceeded (HTTP error 509)
static java.lang.String explainChangesetClosedException(ChangesetClosedException e)
          Explains an exception thrown during upload because the changeset which data is uploaded to is already closed.
static java.lang.String explainClientTimeout(OsmApiException e)
          Explains an OSM API exception because of a client timeout (HTTP 408).
static java.lang.String explainConflict(OsmApiException e)
          Explains an error due to a 409 conflict
static java.lang.String explainException(java.lang.Exception e)
          Explains an Exception to the user.
static java.lang.String explainFailedAuthorisation(OsmApiException e)
           
static java.lang.String explainFailedBasicAuthentication(OsmApiException e)
           
static java.lang.String explainFailedOAuthAuthentication(OsmApiException e)
           
static java.lang.String explainFailedOAuthAuthorisation(OsmApiException e)
           
static java.lang.String explainGeneric(java.lang.Exception e)
          Explains an exception with a generic message dialog
static java.lang.String explainGenericOsmApiException(OsmApiException e)
          Replies a generic error message for an OSM API exception
static java.lang.String explainGoneForUnknownPrimitive(OsmApiException e)
          explains the case of an error due to a delete request on an already deleted OsmPrimitive, i.e.
static java.lang.String explainInternalServerError(OsmTransferException e)
          Explains a OsmApiException which was thrown because of an internal server error in the OSM API server..
static java.lang.String explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e)
          Creates the error message
static java.lang.String explainNestedIllegalDataException(OsmTransferException e)
          Explains a IllegalDataException which has caused an OsmTransferException.
static java.lang.String explainNestedIOException(OsmTransferException e)
          Explains a IOException which has caused an OsmTransferException.
static java.lang.String explainNestedSocketException(OsmTransferException e)
          Explains a SocketException which has caused an OsmTransferException.
static java.lang.String explainNestedUnknownHostException(OsmTransferException e)
          Explains a UnknownHostException which has caused an OsmTransferException.
static java.lang.String explainNotFound(OsmApiException e)
          Explains a OsmApiException which was thrown because a resource wasn't found.
static java.lang.String explainOsmApiInitializationException(OsmApiInitializationException e)
          handles an exception caught during OSM API initialization
static java.lang.String explainOsmTransferException(OsmTransferException e)
          Explains an OsmTransferException to the user.
static java.lang.String explainPreconditionFailed(OsmApiException e)
          Explains an upload error due to a violated precondition, i.e.
static java.lang.String explainSecurityException(OsmTransferException e)
          Explains a SecurityException which has caused an OsmTransferException.
protected static
<T> T
getNestedException(java.lang.Exception e, java.lang.Class<T> nestedClass)
          Replies the first nested exception of type nestedClass (including the root exception e) or null, if no such exception is found.
static Pair<OsmPrimitive,java.util.Collection<OsmPrimitive>> parsePreconditionFailed(java.lang.String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionUtil

private ExceptionUtil()
Method Detail

explainOsmApiInitializationException

public static java.lang.String explainOsmApiInitializationException(OsmApiInitializationException e)
handles an exception caught during OSM API initialization

Parameters:
e - the exception

explainMissingOAuthAccessTokenException

public static java.lang.String explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e)
Creates the error message

Parameters:
e - the exception

parsePreconditionFailed

public static Pair<OsmPrimitive,java.util.Collection<OsmPrimitive>> parsePreconditionFailed(java.lang.String msg)

explainPreconditionFailed

public static java.lang.String explainPreconditionFailed(OsmApiException e)
Explains an upload error due to a violated precondition, i.e. a HTTP return code 412

Parameters:
e - the exception

explainFailedBasicAuthentication

public static java.lang.String explainFailedBasicAuthentication(OsmApiException e)

explainFailedOAuthAuthentication

public static java.lang.String explainFailedOAuthAuthentication(OsmApiException e)

explainFailedAuthorisation

public static java.lang.String explainFailedAuthorisation(OsmApiException e)

explainFailedOAuthAuthorisation

public static java.lang.String explainFailedOAuthAuthorisation(OsmApiException e)

explainClientTimeout

public static java.lang.String explainClientTimeout(OsmApiException e)
Explains an OSM API exception because of a client timeout (HTTP 408).

Parameters:
e - the exception
Returns:
the message

explainGenericOsmApiException

public static java.lang.String explainGenericOsmApiException(OsmApiException e)
Replies a generic error message for an OSM API exception

Parameters:
e - the exception
Returns:
the message

explainConflict

public static java.lang.String explainConflict(OsmApiException e)
Explains an error due to a 409 conflict

Parameters:
e - the exception

explainChangesetClosedException

public static java.lang.String explainChangesetClosedException(ChangesetClosedException e)
Explains an exception thrown during upload because the changeset which data is uploaded to is already closed.

Parameters:
e - the exception

explainGeneric

public static java.lang.String explainGeneric(java.lang.Exception e)
Explains an exception with a generic message dialog

Parameters:
e - the exception

explainSecurityException

public static java.lang.String explainSecurityException(OsmTransferException e)
Explains a SecurityException which has caused an OsmTransferException. This is most likely happening when user tries to access the OSM API from within an applet which wasn't loaded from the API server.

Parameters:
e - the exception

explainNestedSocketException

public static java.lang.String explainNestedSocketException(OsmTransferException e)
Explains a SocketException which has caused an OsmTransferException. This is most likely because there's not connection to the Internet or because the remote server is not reachable.

Parameters:
e - the exception

explainNestedIOException

public static java.lang.String explainNestedIOException(OsmTransferException e)
Explains a IOException which has caused an OsmTransferException. This is most likely happening when the communication with the remote server is interrupted for any reason.

Parameters:
e - the exception

explainNestedIllegalDataException

public static java.lang.String explainNestedIllegalDataException(OsmTransferException e)
Explains a IllegalDataException which has caused an OsmTransferException. This is most likely happening when JOSM tries to load data in in an unsupported format.

Parameters:
e - the exception

explainInternalServerError

public static java.lang.String explainInternalServerError(OsmTransferException e)
Explains a OsmApiException which was thrown because of an internal server error in the OSM API server..

Parameters:
e - the exception

explainBadRequest

public static java.lang.String explainBadRequest(OsmApiException e)
Explains a OsmApiException which was thrown because of a bad request

Parameters:
e - the exception

explainBandwidthLimitExceeded

public static java.lang.String explainBandwidthLimitExceeded(OsmApiException e)
Explains a OsmApiException which was thrown because of bandwidth limit exceeded (HTTP error 509)

Parameters:
e - the exception

explainNotFound

public static java.lang.String explainNotFound(OsmApiException e)
Explains a OsmApiException which was thrown because a resource wasn't found.

Parameters:
e - the exception

explainNestedUnknownHostException

public static java.lang.String explainNestedUnknownHostException(OsmTransferException e)
Explains a UnknownHostException which has caused an OsmTransferException. This is most likely happening when there is an error in the API URL or when local DNS services are not working.

Parameters:
e - the exception

getNestedException

protected static <T> T getNestedException(java.lang.Exception e,
                                          java.lang.Class<T> nestedClass)
Replies the first nested exception of type nestedClass (including the root exception e) or null, if no such exception is found.

Type Parameters:
T -
Parameters:
e - the root exception
nestedClass - the type of the nested exception
Returns:
the first nested exception of type nestedClass (including the root exception e) or null, if no such exception is found.

explainOsmTransferException

public static java.lang.String explainOsmTransferException(OsmTransferException e)
Explains an OsmTransferException to the user.

Parameters:
e - the OsmTransferException

explainGoneForUnknownPrimitive

public static java.lang.String explainGoneForUnknownPrimitive(OsmApiException e)
explains the case of an error due to a delete request on an already deleted OsmPrimitive, i.e. a HTTP response code 410, where we don't know which OsmPrimitive is causing the error.

Parameters:
e - the exception

explainException

public static java.lang.String explainException(java.lang.Exception e)
Explains an Exception to the user.

Parameters:
e - the Exception

escapeReservedCharactersHTML

public static java.lang.String escapeReservedCharactersHTML(java.lang.String s)
Replaces some HTML reserved characters (<, > and &) by their equivalent entity (<, > and &);

Parameters:
s - The unescaped string
Returns:
The escaped string


JOSM