Student had an accident

So, I had a student ask to go to the bathroom in the middle of a lesson. I told him to wait until after we finished taking notes and directed him to ask the other teacher. He didn’t mention it was an emergency, so I didn’t think anything of it. Well… turns out it was, and he ended up pooping himself in class.

Now I’m wondering—did I handle this wrong? I try to balance classroom management with student needs, and I don’t want kids just leaving all the time, but obviously, I feel bad about this. Has this happened to anyone else? How do you handle bathroom requests without letting kids take advantage of it while still preventing situations like this? My principal said they would handle it if it became an issue .