Silencing exception on registered object without onEvent method
See original GitHub issueI have a BaseActivity
class which acts as base for all Android activities in my project.
EventBus.register(this)
is done in the BaseActivity
without any onEvent
methods in it. Some of its subclasses have onEvent
and some don’t. I got this exception when starting activities (subclass of BaseActivity) without onEvent
methods:
Subscriber class com.example.LoginActivity has no public methods called onEvent
That’s obviously because LoginActivity has been registered to EventBus in the super class but has no onEvent
method. However I could get around this problem by putting empty onEvent
in the BaseActivity
(a little bit unclean solution)
I suggest that no exception should be thrown in that case (no onEvent
methods). Let me know what you think.
Thanks
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Chapter 20: Exception Handling Frameworks - Micro Focus
The "raiseException" method is implemented in the Base class and is inherited by all subclasses. If there is no exception handler registered for...
Read more >event loop processing model - HTML - WhatWG
Event handlers, whether registered through the DOM using addEventListener() , by explicit event handler content attributes, by event handler ...
Read more >Promise.prototype.catch() - JavaScript - MDN Web Docs
The catch() method of a Promise object schedules a function to be called when the promise is rejected.
Read more >NullReferenceException when triggering event - Stack Overflow
You need a null check - in C# you can't call events when there are no handlers registered on that event.
Read more >Exception Handling | RESTful Java with JAX-RS 2 ... - dennis-xlc
It will continue this process until there are no more superclasses to match against. Finally, ExceptionMappers are registered with the JAX-RS runtime using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it’d better not to use try-catch here, it’s unnecessary. I prefer provide a value in BaseActivity to indicate if the child need register an event;
If ChildActivity need register, just use like this
I’ve got same issue while working with activity.