It turns out the error message was too long (95000 chars). Not sure where the boundary is, 5000 chars still works ok. I would have expected different behaviour so I guess this is a bug.