Code Monkey home page Code Monkey logo

Comments (5)

dariuszseweryn avatar dariuszseweryn commented on July 30, 2024 1

I see that in your code you do not handle .subscribe() onError(). From the Javadoc you can read that .establishConnection() may emit errors and thus in .subscribe() you should handle the error.

Part of the .establishConnection() Javadoc.

     * @throws BleDisconnectedException emitted when the BLE link has been disconnected either when the connection was already established
     *                                  or was in pending connection state. This occurs when the connection was released as a
     *                                  part of expected behavior (with {@link android.bluetooth.BluetoothGatt#GATT_SUCCESS} state).
     * @throws BleGattException         emitted when the BLE link has been interrupted as a result of an error. The exception contains
     *                                  detailed explanation of the error source (type of operation) and the code proxied from
     *                                  the Android system.

You should use:

.subscribe(
  result -> {},
  throwable -> { /*handle throwable*/ }
)

from rxandroidble.

farmazon3000 avatar farmazon3000 commented on July 30, 2024

I think you are wrong, I DO handle onError in my snippet:

.doOnError(throwable -> {
        Log.d(TAG, "connectionState doOnError: " + throwable);
    })

from rxandroidble.

uKL avatar uKL commented on July 30, 2024

This does not consume errors, they are passed to subscriber anyway. You should handle them in subscribe method or use one of onErrorReturn/onErrorResume

from rxandroidble.

uKL avatar uKL commented on July 30, 2024

@farmazon3000 for further reference go to:
http://stackoverflow.com/questions/30250467/rxjava-what-is-difference-between-callbacks-in-doonerrorcallback-and-subscr

from rxandroidble.

farmazon3000 avatar farmazon3000 commented on July 30, 2024

Thank you guys for pointing it out.

from rxandroidble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.