-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nicer exception messages #303
Changes from all commits
973678c
01b5ec7
8737b62
87de34f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,11 @@ public class BleServiceNotFoundException extends BleException { | |
private final UUID serviceUUID; | ||
|
||
public BleServiceNotFoundException(UUID serviceUUID) { | ||
super("BLE Service not found with uuid " + serviceUUID); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, I'll update in another commit. |
||
this.serviceUUID = serviceUUID; | ||
} | ||
|
||
public UUID getServiceUUID() { | ||
return serviceUUID; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BleServiceNotFoundException{serviceUUID=" + serviceUUID + '}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -518,4 +518,5 @@ class RxBleClientTest extends Specification { | |
Thread.sleep(200) // Nasty :< | ||
true | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary formatting :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, I'll update in another commit. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.polidea.rxandroidble.exceptions | ||
|
||
import android.bluetooth.BluetoothGattCharacteristic | ||
import spock.lang.Specification | ||
|
||
/** | ||
* Tests BleCannotSetCharacteristicNotificationException | ||
*/ | ||
class BleCannotSetCharacteristicNotificationExceptionTest extends Specification { | ||
|
||
BleCannotSetCharacteristicNotificationException objectUnderTest | ||
|
||
BluetoothGattCharacteristic mockCharacteristic = Mock BluetoothGattCharacteristic | ||
|
||
def "toString should include message"() { | ||
|
||
given: | ||
mockCharacteristic.uuid >> new UUID(1, 2) | ||
when: | ||
objectUnderTest = new BleCannotSetCharacteristicNotificationException(mockCharacteristic, | ||
BleCannotSetCharacteristicNotificationException.CANNOT_SET_LOCAL_NOTIFICATION, new Exception("because")) | ||
|
||
then: | ||
assert objectUnderTest.toString() == | ||
"com.polidea.rxandroidble.exceptions.BleCannotSetCharacteristicNotificationException: " + | ||
"Cannot set local notification (code 1) with characteristic UUID 00000000-0000-0001-0000-000000000002" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.polidea.rxandroidble.exceptions | ||
|
||
import spock.lang.Specification | ||
|
||
/** | ||
* Created by jallen on 2017-11-01. | ||
*/ | ||
class BleDisconnectedExceptionTest extends Specification { | ||
|
||
BleDisconnectedException objectUnderTest | ||
|
||
def "toString should include message"() { | ||
|
||
when: | ||
objectUnderTest = new BleDisconnectedException("myBluetoothAddress") | ||
|
||
then: | ||
assert objectUnderTest.toString() == | ||
"com.polidea.rxandroidble.exceptions.BleDisconnectedException: Disconnected from myBluetoothAddress" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good piece of code. I like it :-)