Print connection error to dialog box

Options
I already have something that makes a dialog box, however, I need to find out how to detect an error when connecting to a lobby