mirror of
https://github.com/wharfkit/antelope.git
synced 2026-07-21 17:43:35 +00:00
Adding codingPath to serializer errors
This commit is contained in:
@@ -245,7 +245,11 @@ function decodeObject(value: any, type: ABI.ResolvedType, ctx: DecodingContext):
|
||||
return null
|
||||
}
|
||||
}
|
||||
throw new Error(`Unexpectedly encountered ${value} for non-optional`)
|
||||
throw new Error(
|
||||
`Unexpectedly encountered ${value} for non-optional (${ctx.codingPath
|
||||
.map((path) => path.field)
|
||||
.join('.')})`
|
||||
)
|
||||
} else if (type.isArray) {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new Error('Expected array')
|
||||
|
||||
@@ -179,7 +179,11 @@ export function encodeAny(value: any, type: ABI.ResolvedType, ctx: EncodingConte
|
||||
if (type.isExtension) {
|
||||
return
|
||||
}
|
||||
throw new Error(`Found ${value} for non-optional type: ${type.typeName}`)
|
||||
throw new Error(
|
||||
`Found ${value} for non-optional type: ${type.typeName} (${ctx.codingPath
|
||||
.map((path) => path.field)
|
||||
.join('.')})`
|
||||
)
|
||||
}
|
||||
if (abiType && abiType.toABI) {
|
||||
// type explicitly handles encoding
|
||||
|
||||
Reference in New Issue
Block a user