mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 08:12:05 +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() {
|
public String getErrorMessage() {
|
||||||
String error;
|
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
error = "No error logged";
|
return "No error logged";
|
||||||
}
|
}
|
||||||
else {
|
return "'" + toString() + "' failed because " + exception.toString();
|
||||||
error = exception.getMessage();
|
|
||||||
}
|
|
||||||
return toString() + " Exception: " + error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class SmackExceptionTest {
|
||||||
|
|
||||||
ConnectionException connectionException = ConnectionException.from(failedAddresses);
|
ConnectionException connectionException = ConnectionException.from(failedAddresses);
|
||||||
String message = connectionException.getMessage();
|
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);
|
message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue