mirror of
				https://github.com/nerzhul/ownCloud-SMS-App.git
				synced 2025-10-28 08:57:43 +00:00 
			
		
		
		
	Properly handle InvalidArgumentException when URI is not valid in HTTP connector
This fixes issue #149
This commit is contained in:
		
							parent
							
								
									bc9f36d80b
								
							
						
					
					
						commit
						c682d7fd0d
					
				| @ -260,15 +260,20 @@ public class LoginActivity extends AppCompatActivity { | ||||
| 		protected Boolean doInBackground(Void... params) { | ||||
| 			_returnCode = 0; | ||||
| 			OCHttpClient http = new OCHttpClient(getBaseContext(), _serverURI, _login, _password); | ||||
| 			GetMethod testMethod = http.getVersion(); | ||||
| 			GetMethod testMethod = null; | ||||
| 			try { | ||||
| 				testMethod = http.getVersion(); | ||||
| 				_returnCode = http.execute(testMethod); | ||||
| 			} catch (IllegalArgumentException e) { | ||||
| 				Log.w(TAG, "Failed to getVersion, IllegalArgumentException occured: " + e.getMessage()); | ||||
| 				_returnCode = 597; | ||||
| 			} catch (IOException e) { | ||||
| 				Log.w(TAG, "Failed to login, IOException occured: " + e.getMessage()); | ||||
| 				_returnCode = 599; | ||||
| 			} | ||||
| 
 | ||||
| 			testMethod.releaseConnection(); | ||||
| 			if (testMethod != null) | ||||
| 				testMethod.releaseConnection(); | ||||
| 
 | ||||
| 			return (_returnCode == 200); | ||||
| 		} | ||||
| @ -322,6 +327,9 @@ public class LoginActivity extends AppCompatActivity { | ||||
| 					case 404: | ||||
| 						_serverView.setError(getString(R.string.error_connection_failed_not_found)); | ||||
| 						break; | ||||
| 					case 597: | ||||
| 						_serverView.setError(getString(R.string.error_invalid_server_address)); | ||||
| 						break; | ||||
| 					case 400: | ||||
| 					case 598: | ||||
| 						_serverView.setError(getString(R.string.error_connection_failed)); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user