Skip to content

[BUG] Not enough contextual parsing information when a MapMaid parsing exception occurs #84

@quantummaiddeveloper

Description

@quantummaiddeveloper

To Reproduce

class MyDto(val field1: String, val field2: String)

fun main() {

    val mapMaid = MapMaid.aMapMaid()
            .serializingAndDeserializing(MyDto::class.java)
            .build()
    mapMaid.deserializeJson(
            """
            {
                "field1": [],
                "field2": "b"
            }
            """, MyDto::class.java)
}

Exception:

Exception in thread "main" de.quantummaid.mapmaid.debug.MapMaidException: Requiring the input to be an 'string' but found '[]' at 'field1'

java.lang.String:
Mode: duplex
How it is serialized:
	toString()
Why it needs to be serializable:
	- xy.test.MyDto -> manually added
How it is deserialized:
	does not require deserialization
Why it needs to be deserializable:
	- xy.test.MyDto -> manually added



Please visit our documentation at 'https://github.com/quantummaid/mapmaid/tree/master/documentation' for additional help.

	at de.quantummaid.mapmaid.debug.MapMaidException.mapMaidException(MapMaidException.java:69)
	at de.quantummaid.mapmaid.debug.MapMaidException.mapMaidException(MapMaidException.java:53)
	at de.quantummaid.mapmaid.debug.MapMaidException.mapMaidException(MapMaidException.java:41)
	at de.quantummaid.mapmaid.mapper.deserialization.WrongInputStructure.wrongInputStructureException(WrongInputStructure.java:48)
	at de.quantummaid.mapmaid.mapper.deserialization.deserializers.TypeDeserializer.castSafely(TypeDeserializer.java:63)
	at de.quantummaid.mapmaid.mapper.deserialization.deserializers.customprimitives.CustomPrimitiveDeserializer.deserialize(CustomPrimitiveDeserializer.java:75)
	at de.quantummaid.mapmaid.mapper.deserialization.InternalDeserializer.deserializeRecursive(InternalDeserializer.java:108)
	at de.quantummaid.mapmaid.mapper.deserialization.deserializers.serializedobjects.SerializedObjectDeserializer.deserialize(SerializedObjectDeserializer.java:82)
	at de.quantummaid.mapmaid.mapper.deserialization.InternalDeserializer.deserializeRecursive(InternalDeserializer.java:108)
	at de.quantummaid.mapmaid.mapper.deserialization.InternalDeserializer.deserialize(InternalDeserializer.java:71)
	at de.quantummaid.mapmaid.mapper.deserialization.Deserializer.deserialize(Deserializer.java:121)
	at de.quantummaid.mapmaid.mapper.deserialization.Deserializer.deserialize(Deserializer.java:103)
	at de.quantummaid.mapmaid.MapMaid.deserialize(MapMaid.java:277)
	at de.quantummaid.mapmaid.MapMaid.deserializeJson(MapMaid.java:177)
	at de.quantummaid.mapmaid.MapMaid.deserializeJson(MapMaid.java:162)
	at de.quantummaid.mapmaid.MapMaid.deserializeJson(MapMaid.java:158)
	at de.quantummaid.mapmaid.MapMaid.deserializeJson(MapMaid.java:153)
	at xy.test.MainKt.main(Main.kt:12)
	at xy.test.MainKt.main(Main.kt)

Process finished with exit code 1

Expected behavior
Should contain original input (JSON in this case).

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions