Giter Club home page Giter Club logo

Comments (7)

swankjesse avatar swankjesse commented on June 9, 2024

We need to fix the code generator to reject this. The currently-supported solution is to put a try/catch in your @Provides-annotated method. This is lame, I agree, but it's very transparent.

from dagger.

pforhan avatar pforhan commented on June 9, 2024

Now, you can still have this blow up your app, if you throw a RuntimeException from the catch block...

from dagger.

cgruber avatar cgruber commented on June 9, 2024

Indeed. This is the universal danger of provides methods. They do
things at run time that are hard to analyse at compile time. We can
only show your wiring to be structurally valid. We cannot prove you
will have no errors at run time.

from dagger.

arichiardi avatar arichiardi commented on June 9, 2024

I mean, it is ok to have Runtime failures like these. My app needs a XmlPullParser to work. I was just suggesting that Dagger doesn't have to interfere with the developer here. But you already know that :)

from dagger.

cgruber avatar cgruber commented on June 9, 2024

Should we reject this, or wrap this in a try/catch block and run-time exception in the generated code. It is boiler plate, so it's reasonable to generate, and the try/catch code will be clear within the generated code, just as readable.

Heck, we could even generate run-time exceptions for checked exceptions that wrap them.

Then again, doing so would pretty much pervert the whole approach of checked-exceptions. Whether you're for or against that is sort of a matter of religion.

from dagger.

arichiardi avatar arichiardi commented on June 9, 2024

IMHO, to avoid perversion ("why is this freaking framework throwing something different here?") and avoid a catch (Exception everything) block, which is always bad, you should reject it.

from dagger.

cgruber avatar cgruber commented on June 9, 2024

Yeah - I think I agree. Just wanted to put it out for consideration.

from dagger.

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.