1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 00:02:06 +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:
Florian Schmaus 2015-01-18 18:57:08 +01:00
parent 0bcd3d9356
commit 9ae66cc747
2 changed files with 3 additions and 7 deletions

View file

@ -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();
}
}

View file

@ -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);
}