fix: use toJSON
for error serialization
#5526
Merged
toJSON
for error serialization
#5526