Skip to content
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

Extend ILogger interface to pass Throwables in warning/error calls #168

Open
mrsasha opened this issue Mar 20, 2018 · 1 comment
Open

Extend ILogger interface to pass Throwables in warning/error calls #168

mrsasha opened this issue Mar 20, 2018 · 1 comment
Assignees
Milestone

Comments

@mrsasha
Copy link
Member

mrsasha commented Mar 20, 2018

That way their stacktraces can be printed.

@mrsasha mrsasha self-assigned this Mar 20, 2018
@mrsasha mrsasha added this to the 1.0 milestone Mar 20, 2018
@sdoward
Copy link

sdoward commented Mar 22, 2018

The debug option is working great to identify issues. I think the exceptions can be improved upon, to allow for easier debugging especially in production.

At the moment we receive stacktraces such as the one attached at the bottom of this comment. It gives a stacktrace for the library but no indication of what the consumer of AndroidBound has done wrong.

I would propose the following when propagating errors (wether to a logger or throwing)

1. Throw BindingExceptions that give information on what went wrong.

These would be used when a binding is incorrect. The data would likely be in the form of the message. Data that could be provided..

  • File/Line of XML were the binding has been configured incorrectly
  • ViewModel file/line/method that is not conforming to the binding as expected
  • Converter file/line/method that is not conforming to the binding as expected

There could potentially be a number of binding Exceptions.

  • NoBindingMethodException- when a method is not found in a view model
  • IncorrectTypeBindingException - when using a wrong data type e.g. int instead of String
    These exceptions would likely be closely matched to reflection errors

2. Throw original Exceptions when an exception is received from a method call

In other occasions the binding could be correct but when AndroidBound is calling a method via reflection an exception might be received. For example a NullPointerException might be thrown from a consumers code. This is likely to be a bug in their code. This exception should be thrown/logged directly and not wrapped in a RuntimeException so the consumers can easily see the stacktrace.

I don't know the ins and out of this lib too well so I don't know how difficult these things are to achieve.

Fatal Exception: java.lang.RuntimeException: Cannot get value for property Execute of type class java.lang.Object: property is non-existent
       at solutions.alterego.androidbound.binding.types.PropertyBinding.getValue(PropertyBinding.java:77)
       at solutions.alterego.androidbound.binding.BindingAssociationEngine.<init>(BindingAssociationEngine.java:71)
       at solutions.alterego.androidbound.binding.TextSpecificationBinder.bind(TextSpecificationBinder.java:54)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.bindViewToSource(ViewBindingEngine.java:118)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.checkAndBindView(ViewBindingEngine.java:98)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.checkAndBindView(ViewBindingEngine.java:96)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.checkAndBindView(ViewBindingEngine.java:96)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.checkAndBindView(ViewBindingEngine.java:96)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.checkAndBindView(ViewBindingEngine.java:96)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.checkAndBindView(ViewBindingEngine.java:96)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.checkAndBindView(ViewBindingEngine.java:96)
       at solutions.alterego.androidbound.binding.ViewBindingEngine.lazyBindView(ViewBindingEngine.java:88)
       at solutions.alterego.androidbound.support.android.adapters.BindableRecyclerViewItemViewHolder.bindTo(BindableRecyclerViewItemViewHolder.java:72)
       at solutions.alterego.androidbound.support.android.adapters.BindableRecyclerViewItemViewHolder.onBindViewHolderWithParentLayoutParams(BindableRecyclerViewItemViewHolder.java:39)
       at solutions.alterego.androidbound.support.android.adapters.BindableRecyclerViewAdapter.onBindViewHolder(BindableRecyclerViewAdapter.java:89)
       at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6508)
       at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6541)
       at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5484)
       at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5750)
       at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589)
       at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585)
       at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231)
       at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558)
       at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)
       at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610)
       at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719)
       at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3135)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:719)
       at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:91)
       at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1361)
       at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:789)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
       at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
       at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
       at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
       at com.android.internal.policy.DecorView.onMeasure(DecorView.java:690)
       at android.view.View.measure(View.java:19861)
       at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
       at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1366)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6344)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
       at android.view.Choreographer.doCallbacks(Choreographer.java:686)
       at android.view.Choreographer.doFrame(Choreographer.java:621)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6121)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

@mrsasha mrsasha modified the milestones: 1.0, 0.10 Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants