Added proper error handling when the GetCapabilities request failed, so that the surrounding program can act accordingly.