Detect serialization failures and raise special exception in this case