JsonParseException (Gson 2.3.1 API)
Date: 2014-11-20

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gson
Class JsonParseException

    java.lang.Object
      java.lang.Throwable
          java.lang.Exception
              java.lang.RuntimeException
                  com.google.gson.JsonParseException

All Implemented Interfaces:
  Serializable

Direct Known Subclasses:
  JsonIOException, JsonSyntaxException

    public class JsonParseException

extends RuntimeException

This exception is raised if there is a serious issue that occurs during parsing of a Json string. One of the main usages for this class is for the Gson infrastructure. If the incoming Json is bad/malicious, an instance of this exception is raised.

This exception is a `RuntimeException` because it is exposed to the client. Using a `RuntimeException` avoids bad coding practices on the client side where they catch the exception and do nothing. It is often the case that you want to blow up if there is a parsing error (i.e. often clients do not know how to recover from a `JsonParseException`.

Author:
  Inderjeet Singh, Joel Leitch
See Also:
  Serialized Form

Constructor Summary
`JsonParseException(String msg)` Creates exception with the specified message.
`JsonParseException(String msg, Throwable cause)` Creates exception with the specified message and cause.
`JsonParseException(Throwable cause)` Creates exception with the specified cause.

Method Summary

Methods inherited from class java.lang.Throwable
`fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### JsonParseException

    public JsonParseException(String msg)

  Creates exception with the specified message. If you are wrapping another exception, consider using `JsonParseException(String, Throwable)` instead.

  Parameters:
    `msg` - error message describing a possible cause of this exception.

### JsonParseException

    public JsonParseException(String msg,
                              Throwable cause)

  Creates exception with the specified message and cause.

  Parameters:
    `msg` - error message describing what happened.
    `cause` - root exception that caused this exception to be thrown.

### JsonParseException

    public JsonParseException(Throwable cause)

  Creates exception with the specified cause. Consider using `JsonParseException(String, Throwable)` instead if you can describe what happened.

  Parameters:
    `cause` - root exception that caused this exception to be thrown.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008–2014 Google, Inc.. All rights reserved.