Convert exceptions to Kotlin (#1483)

* Rename .java to .kt

* Convert exceptions to kotlin

* Add missing empty constructor
This commit is contained in:
Zac Sweers
2022-01-10 11:07:48 -05:00
committed by GitHub
parent 56e1ae6404
commit 32932cfb40
2 changed files with 13 additions and 29 deletions

View File

@@ -13,34 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.moshi;
import javax.annotation.Nullable;
package com.squareup.moshi
/**
* 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
* 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.
*
* <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
* {@link StackOverflowError}.
* [StackOverflowError].
*/
public final class JsonDataException extends RuntimeException {
public JsonDataException() {}
public JsonDataException(@Nullable String message) {
super(message);
}
public JsonDataException(@Nullable Throwable cause) {
super(cause);
}
public JsonDataException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
public class JsonDataException : RuntimeException {
public constructor() : super()
public constructor(message: String?) : super(message)
public constructor(cause: Throwable?) : super(cause)
public constructor(message: String?, cause: Throwable?) : super(message, cause)
}

View File

@@ -13,14 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.squareup.moshi;
package com.squareup.moshi
import java.io.IOException;
import javax.annotation.Nullable;
import java.io.IOException
/** Thrown when the data being parsed is not encoded as valid JSON. */
public final class JsonEncodingException extends IOException {
public JsonEncodingException(@Nullable String message) {
super(message);
}
}
public class JsonEncodingException(message: String?) : IOException(message)