Manage WIFI connection failure with ESP as arduino module

I just read the post :
ESP8266 + NTP
and I found the J-M-L's contribution excellent. Thanks to him I am able now to use an ESP8266 as a wifi module for arduino and that's not an easy thing.
One point remains unsolved for me : when the wifi hot spot is down, the pg crashes when trying to get NTP sync for instance. How to manage errors with exceptions or how to retrieve the msg of connection failure returned by AT commands.
Thsk so much J-M-L !!!

OK I got it :
is_connected=espATCommand("AT+CWJAP="SSID","psswd"", "CONNECTED", LONG_PAUSE); // connect to wifi
if (is_connected) Serial.println("is connected"); else Serial.println("is non connected");