Class ServiceException

  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by net.degreedays.api.DegreeDaysApiException
                  extended by net.degreedays.api.FailureException
                      extended by net.degreedays.api.RequestFailureException
                          extended by net.degreedays.api.ServiceException
All Implemented Interfaces:

public final class ServiceException
extends RequestFailureException

Indicates that the API servers failed to process a request because of temporary downtime or an unexpected error (sorry!).

This exception corresponds to any failure code starting with "Service".

You can interrogate the isDueToXXX() methods of this exception to find out more about the cause. But do note that it is possible for none of those methods to return true if a relevant new failure code is added into the API. Be prepared for this in your handling.

Method Summary
 boolean isDueToServiceTemporarilyDown()
          Returns true if this failure was caused by a temporary problem preventing the API service from functioning properly (sorry!).
 boolean isDueToServiceUnexpectedError()
          Returns true if this failure was caused by a unexpected error in the API service (sorry!).
Methods inherited from class net.degreedays.api.RequestFailureException
Methods inherited from class net.degreedays.api.FailureException
failure, getMessage
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Method Detail


public boolean isDueToServiceTemporarilyDown()
Returns true if this failure was caused by a temporary problem preventing the API service from functioning properly (sorry!).

This might, for example, be caused by a temporary network error preventing our API servers from accessing the database of weather data that the calculation process relies upon. Or it could be caused by other essential systems being overloaded.

The best way to handle this type of failure is usually to try the request again until it works (waiting a little while between repeated submissions). If you get this type of failure for one request, it is quite likely that some or all of your requests will fail in the same way until the problem is resolved (which hopefully won't take long).

See Also:
Failure codes, isDueToXXX() methods


public boolean isDueToServiceUnexpectedError()
Returns true if this failure was caused by a unexpected error in the API service (sorry!).

If an unexpected error in the API service should occur, it is quite likely that it would only be triggered by a specific request (e.g. a request for data from a particular weather station). This is different to the service going temporarily down and affecting most or all requests until the problem is resolved.

If a request triggers a "ServiceUnexpectedError" failure, there probably won't be any point in trying that particular request repeatedly. Other requests will probably continue to work OK, but the problem request, if repeatedly submitted, will probably repeatedly fail until the underlying bug in the system is addressed. This is the sort of thing that would typically take at least a day or two, or potentially much longer (some bugs are beyond our sphere of control).

If you're getting this type of failure repeatedly, and it's getting in the way of what you're trying to achieve with the API, please email us to let us know. Our logging system should alert us each time an error like this occurs, but it's always useful to hear more information. Also, if it's not something we can fix on our end, we might well be able to suggest some sort of workaround.

See Also:
Failure codes, isDueToXXX() methods