mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Convert exceptions to Kotlin (#1483)
* Rename .java to .kt * Convert exceptions to kotlin * Add missing empty constructor
This commit is contained in:
@@ -13,34 +13,23 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.squareup.moshi;
|
package com.squareup.moshi
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when the data in a JSON document doesn't match the data expected by the caller. For
|
* Thrown when the data in a JSON document doesn't match the data expected by the caller. For
|
||||||
* example, suppose the application expects a boolean but the JSON document contains a string. When
|
* example, suppose the application expects a boolean but the JSON document contains a string. When
|
||||||
* the call to {@link JsonReader#nextBoolean} is made, a {@code JsonDataException} is thrown.
|
* the call to [JsonReader.nextBoolean] is made, a `JsonDataException` is thrown.
|
||||||
*
|
*
|
||||||
* <p>Exceptions of this type should be fixed by either changing the application code to accept the
|
* Exceptions of this type should be fixed by either changing the application code to accept the
|
||||||
* unexpected JSON, or by changing the JSON to conform to the application's expectations.
|
* unexpected JSON, or by changing the JSON to conform to the application's expectations.
|
||||||
*
|
*
|
||||||
* <p>This exception may also be triggered if a document's nesting exceeds 31 levels. This depth is
|
* This exception may also be triggered if a document's nesting exceeds 31 levels. This depth is
|
||||||
* sufficient for all practical applications, but shallow enough to avoid uglier failures like
|
* sufficient for all practical applications, but shallow enough to avoid uglier failures like
|
||||||
* {@link StackOverflowError}.
|
* [StackOverflowError].
|
||||||
*/
|
*/
|
||||||
public final class JsonDataException extends RuntimeException {
|
public class JsonDataException : RuntimeException {
|
||||||
public JsonDataException() {}
|
public constructor() : super()
|
||||||
|
public constructor(message: String?) : super(message)
|
||||||
public JsonDataException(@Nullable String message) {
|
public constructor(cause: Throwable?) : super(cause)
|
||||||
super(message);
|
public constructor(message: String?, cause: Throwable?) : super(message, cause)
|
||||||
}
|
|
||||||
|
|
||||||
public JsonDataException(@Nullable Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonDataException(@Nullable String message, @Nullable Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -13,14 +13,9 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.squareup.moshi;
|
package com.squareup.moshi
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/** Thrown when the data being parsed is not encoded as valid JSON. */
|
/** Thrown when the data being parsed is not encoded as valid JSON. */
|
||||||
public final class JsonEncodingException extends IOException {
|
public class JsonEncodingException(message: String?) : IOException(message)
|
||||||
public JsonEncodingException(@Nullable String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user