-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing decodeNotNullMark() that causes an exception (#40)
fixing decodeNotNullMark() that causes an exception ### What's done: - fixing bug and changing the logic for Nullable fields - adding custom exceptions
- Loading branch information
Showing
7 changed files
with
79 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 14 additions & 7 deletions
21
ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/exceptions/Exceptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
package com.akuleshov7.ktoml.exceptions | ||
|
||
class TomlParsingException(message: String, lineNo: Int) : Exception("Line $lineNo: $message") | ||
open class KtomlException(message: String) : Exception(message) | ||
|
||
class InternalParsingException(message: String, lineNo: Int) : Exception("Line $lineNo: $message") | ||
class TomlParsingException(message: String, lineNo: Int) : KtomlException("Line $lineNo: $message") | ||
|
||
class InternalDecodingException(message: String) : Exception(message) | ||
class InternalParsingException(message: String, lineNo: Int) : KtomlException("Line $lineNo: $message") | ||
|
||
class InternalAstException(message: String) : Exception(message) | ||
class InternalDecodingException(message: String) : KtomlException(message) | ||
|
||
class UnknownNameDecodingException(keyField: String, parent: String?) : Exception( | ||
class InternalAstException(message: String) : KtomlException(message) | ||
|
||
class UnknownNameDecodingException(keyField: String, parent: String?) : KtomlException( | ||
"Unknown key received: <$keyField> in scope <$parent>." + | ||
" Pass 'ignoreUnknownNames' option if you would like to skip unknown keys" | ||
) | ||
|
||
class InvalidEnumValueException(value: String, availableEnumValues: String) : Exception( | ||
class InvalidEnumValueException(value: String, availableEnumValues: String) : KtomlException( | ||
"Value $value is not a valid" + | ||
" option, permitted choices are: $availableEnumValues" | ||
) | ||
|
||
class MissingRequiredFieldException(message: String) : Exception(message) | ||
class NonNullableValueException(field: String, lineNo: Int) : KtomlException( | ||
"Not-nullable field <$field> got a null value in the input. Please check the input (line: <$lineNo>)" + | ||
" or make the field nullable" | ||
) | ||
|
||
class MissingRequiredFieldException(message: String) : KtomlException(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
ktoml-core/src/commonTest/resources/class_cast_regression1.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
a = 1 | ||
b = null | ||
c = 2 | ||
d = null |
4 changes: 4 additions & 0 deletions
4
ktoml-core/src/commonTest/resources/class_cast_regression2.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
a = null | ||
b = 1 | ||
c = 2 | ||
d = null |