mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +01:00
Use Exception.getString in HostAddress
instead of getMessage(), because some Exceptions, e.g. Android's NetworkOnMainThreadException, will return null on getMessage(). Exception.toString() does what we want, i.e. returns - the exception class name - and the return value of getLocalizedMessage()
This commit is contained in:
parent
0bcd3d9356
commit
9ae66cc747
2 changed files with 3 additions and 7 deletions
|
@ -109,13 +109,9 @@ public class HostAddress {
|
|||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
String error;
|
||||
if (exception == null) {
|
||||
error = "No error logged";
|
||||
return "No error logged";
|
||||
}
|
||||
else {
|
||||
error = exception.getMessage();
|
||||
}
|
||||
return toString() + " Exception: " + error;
|
||||
return "'" + toString() + "' failed because " + exception.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class SmackExceptionTest {
|
|||
|
||||
ConnectionException connectionException = ConnectionException.from(failedAddresses);
|
||||
String message = connectionException.getMessage();
|
||||
assertEquals("The following addresses failed: foo.bar.example:1234 Exception: Failed for some reason, barz.example:5678 Exception: Failed for some other reason",
|
||||
assertEquals("The following addresses failed: 'foo.bar.example:1234' failed because java.lang.Exception: Failed for some reason, 'barz.example:5678' failed because java.lang.Exception: Failed for some other reason",
|
||||
message);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue