server_events: Extract functions for managing connection errors.
server_events: Extract functions for managing connection errors.

This cuts a bit of code duplication.

andersk/zulip,synicalsyntax/zulip,eeshangarg/zulip,synicalsyntax/zulip,rishig/zulip,shubhamdhama/zulip,kou/zulip,brainwane/zulip,rht/zulip,punchagan/zulip,eeshangarg/zulip,brainwane/zulip,dhcrzf/zulip,hackerkid/zulip,timabbott/zulip,kou/zulip,jackrzhang/zulip,tommyip/zulip,zulip/zulip,hackerkid/zulip,hackerkid/zulip,rht/zulip,timabbott/zulip,jackrzhang/zulip,eeshangarg/zulip,kou/zulip,zulip/zulip,shubhamdhama/zulip,punchagan/zulip,timabbott/zulip,punchagan/zulip,tommyip/zulip,punchagan/zulip,kou/zulip,dhcrzf/zulip,punchagan/zulip,shubhamdhama/zulip,andersk/zulip,timabbott/zulip,showell/zulip,rht/zulip,jackrzhang/zulip,timabbott/zulip,andersk/zulip,dhcrzf/zulip,showell/zulip,punchagan/zulip,andersk/zulip,kou/zulip,rishig/zulip,shubhamdhama/zulip,rishig/zulip,showell/zulip,rishig/zulip,hackerkid/zulip,tommyip/zulip,hackerkid/zulip,rht/zulip,synicalsyntax/zulip,jackrzhang/zulip,synicalsyntax/zulip,dhcrzf/zulip,synicalsyntax/zulip,hackerkid/zulip,jackrzhang/zulip,jackrzhang/zulip,dhcrzf/zulip,eeshangarg/zulip,andersk/zulip,shubhamdhama/zulip,andersk/zulip,showell/zulip,tommyip/zulip,rht/zulip,brainwane/zulip,timabbott/zulip,brainwane/zulip,showell/zulip,zulip/zulip,zulip/zulip,showell/zulip,andersk/zulip,zulip/zulip,rishig/zulip,jackrzhang/zulip,shubhamdhama/zulip,rht/zulip,tommyip/zulip,dhcrzf/zulip,kou/zulip,brainwane/zulip,brainwane/zulip,hackerkid/zulip,zulip/zulip,kou/zulip,punchagan/zulip,rishig/zulip,tommyip/zulip,brainwane/zulip,showell/zulip,rht/zulip,zulip/zulip,rishig/zulip,shubhamdhama/zulip,dhcrzf/zulip,tommyip/zulip,eeshangarg/zulip,eeshangarg/zulip,synicalsyntax/zulip,synicalsyntax/zulip,eeshangarg/zulip,timabbott/zulip