Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Exception thrown from @Background method, is not logged  #2164

@marmor7

Description

@marmor7

I've read #646, #677 and #682 they all talk about not hiding an exception thrown from @background from the global exception handler.
That works fine (Crashlytics gets the exceptions), but to get the thrown exception behaving like a regular exception it needs to be logged onto LogCat as well, currently the crash is hidden from logs.

The proper handling code should also have e.printStackTrace();

AndroidAnnotations version: 4.4.0

Android compile SDK version: 26

Annotated code:

@Background
methodInBackground() { ... }

Expected generated code:

BackgroundExecutor.execute(new BackgroundExecutor.Task("", 0L, "") {

            @Override
            public void execute() {
                try {
                    MyActivity_.super.methodInBackground();
                } catch (final Throwable e) {
                    Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
                    e.printStackTrace(); // NEW
                }
            }
        }
        );

Actual generated code:

BackgroundExecutor.execute(new BackgroundExecutor.Task("", 0L, "") {

            @Override
            public void execute() {
                try {
                    MyActivity_.super.methodInBackground();
                } catch (final Throwable e) {
                    Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
                }
            }
        }
        );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions