phonegap: error handling