Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4489c8a3 authored by Shai Barack's avatar Shai Barack
Browse files

Don't append inner exception to exception message

Don't:
```
new RuntimeException("Foo failed, reason: " + cause, cause);
```

Do:
```
new RuntimeException("Foo failed", cause);
```

Saves work.
Generates fewer instructions.

Flag: EXEMPT refactor
Change-Id: I1d7b396f0eb3509d384bd448f024df9cde41b139
parent 4db80507
Loading
Loading
Loading
Loading
+27 −44
Original line number Diff line number Diff line
@@ -4220,8 +4220,7 @@ public final class ActivityThread extends ClientTransactionHandler
        } catch (Exception e) {
            if (!mInstrumentation.onException(activity, e)) {
                throw new RuntimeException(
                    "Unable to instantiate activity " + component
                    + ": " + e.toString(), e);
                    "Unable to instantiate activity " + component, e);
            }
        }

@@ -4314,8 +4313,7 @@ public final class ActivityThread extends ClientTransactionHandler
        } catch (Exception e) {
            if (!mInstrumentation.onException(activity, e)) {
                throw new RuntimeException(
                    "Unable to start activity " + component
                    + ": " + e.toString(), e);
                    "Unable to start activity " + component, e);
            }
        }

@@ -5067,8 +5065,7 @@ public final class ActivityThread extends ClientTransactionHandler
                    "Finishing failed broadcast to " + data.intent.getComponent());
            data.sendFinished(mgr);
            throw new RuntimeException(
                "Unable to instantiate receiver " + component
                + ": " + e.toString(), e);
                "Unable to instantiate receiver " + component, e);
        }

        long debugStoreId = -1;
@@ -5095,8 +5092,7 @@ public final class ActivityThread extends ClientTransactionHandler
            data.sendFinished(mgr);
            if (!mInstrumentation.onException(receiver, e)) {
                throw new RuntimeException(
                    "Unable to start receiver " + component
                    + ": " + e.toString(), e);
                    "Unable to start receiver " + component, e);
            }
        } finally {
            sCurrentBroadcastIntent.set(null);
@@ -5213,7 +5209,7 @@ public final class ActivityThread extends ClientTransactionHandler
                } catch (Exception e) {
                    // If this is during restore, fail silently; otherwise go
                    // ahead and let the user see the crash.
                    Slog.e(TAG, "Agent threw during creation: " + e);
                    Slog.e(TAG, "Agent threw during creation", e);
                    if (data.backupMode != ApplicationThreadConstants.BACKUP_MODE_RESTORE
                            && data.backupMode !=
                                    ApplicationThreadConstants.BACKUP_MODE_RESTORE_FULL) {
@@ -5231,7 +5227,7 @@ public final class ActivityThread extends ClientTransactionHandler
            }
        } catch (Exception e) {
            throw new RuntimeException("Unable to create BackupAgent "
                    + classname + ": " + e.toString(), e);
                    + classname, e);
        }
    }

@@ -5351,8 +5347,7 @@ public final class ActivityThread extends ClientTransactionHandler
        } catch (Exception e) {
            if (!mInstrumentation.onException(service, e)) {
                throw new RuntimeException(
                    "Unable to create service " + data.info.name
                    + ": " + e.toString(), e);
                    "Unable to create service " + data.info.name, e);
            }
        }
    }
@@ -5384,7 +5379,7 @@ public final class ActivityThread extends ClientTransactionHandler
                if (!mInstrumentation.onException(s, e)) {
                    throw new RuntimeException(
                            "Unable to bind to service " + s
                            + " with " + data.intent + ": " + e.toString(), e);
                            + " with " + data.intent, e);
                }
            }
        }
@@ -5414,7 +5409,7 @@ public final class ActivityThread extends ClientTransactionHandler
                if (!mInstrumentation.onException(s, e)) {
                    throw new RuntimeException(
                            "Unable to unbind to service " + s
                            + " with " + data.intent + ": " + e.toString(), e);
                            + " with " + data.intent, e);
                }
            }
        }
@@ -5528,7 +5523,7 @@ public final class ActivityThread extends ClientTransactionHandler
                if (!mInstrumentation.onException(s, e)) {
                    throw new RuntimeException(
                            "Unable to start service " + s
                            + " with " + data.args + ": " + e.toString(), e);
                            + " with " + data.args, e);
                }
            }
        }
@@ -5558,9 +5553,7 @@ public final class ActivityThread extends ClientTransactionHandler
                }
            } catch (Exception e) {
                if (!mInstrumentation.onException(s, e)) {
                    throw new RuntimeException(
                            "Unable to stop service " + s
                            + ": " + e.toString(), e);
                    throw new RuntimeException("Unable to stop service " + s, e);
                }
                Slog.i(TAG, "handleStopService: exception for " + token, e);
            }
@@ -5584,8 +5577,7 @@ public final class ActivityThread extends ClientTransactionHandler
            } catch (Exception e) {
                if (!mInstrumentation.onException(s, e)) {
                    throw new RuntimeException(
                            "Unable to call onTimeout on service " + s
                                    + ": " + e.toString(), e);
                            "Unable to call onTimeout on service " + s, e);
                }
                Slog.i(TAG, "handleTimeoutService: exception for " + token, e);
            }
@@ -5605,7 +5597,7 @@ public final class ActivityThread extends ClientTransactionHandler
            } catch (Exception e) {
                if (!mInstrumentation.onException(s, e)) {
                    throw new RuntimeException(
                            "Unable to call onTimeLimitExceeded on service " + s + ": " + e, e);
                            "Unable to call onTimeLimitExceeded on service " + s, e);
                }
                Slog.i(TAG, "handleTimeoutServiceForType: exception for " + token, e);
            }
@@ -5672,7 +5664,7 @@ public final class ActivityThread extends ClientTransactionHandler
        } catch (Exception e) {
            if (!mInstrumentation.onException(r.activity, e)) {
                throw new RuntimeException("Unable to resume activity "
                        + r.intent.getComponent().toShortString() + ": " + e.toString(), e);
                        + r.intent.getComponent().toShortString(), e);
            }
        }
        return true;
@@ -5971,7 +5963,7 @@ public final class ActivityThread extends ClientTransactionHandler
        } catch (Exception e) {
            if (!mInstrumentation.onException(r.activity, e)) {
                throw new RuntimeException("Unable to pause activity "
                        + safeToComponentShortString(r.intent) + ": " + e.toString(), e);
                        + safeToComponentShortString(r.intent), e);
            }
        }
        r.setState(ON_PAUSE);
@@ -6051,8 +6043,7 @@ public final class ActivityThread extends ClientTransactionHandler
                if (!mInstrumentation.onException(r.activity, e)) {
                    throw new RuntimeException(
                            "Unable to save state of activity "
                            + r.intent.getComponent().toShortString()
                            + ": " + e.toString(), e);
                            + r.intent.getComponent().toShortString(), e);
                }
            }
        }
@@ -6084,8 +6075,7 @@ public final class ActivityThread extends ClientTransactionHandler
            if (!mInstrumentation.onException(r.activity, e)) {
                throw new RuntimeException(
                        "Unable to stop activity "
                                + r.intent.getComponent().toShortString()
                                + ": " + e.toString(), e);
                                + r.intent.getComponent().toShortString(), e);
            }
        }
        r.setState(ON_STOP);
@@ -6241,8 +6231,7 @@ public final class ActivityThread extends ClientTransactionHandler
                if (!mInstrumentation.onException(r.activity, e)) {
                    throw new RuntimeException(
                            "Failure delivering result " + ri + " to activity "
                            + r.intent.getComponent().toShortString()
                            + ": " + e.toString(), e);
                            + r.intent.getComponent().toShortString(), e);
                }
            }
        }
@@ -6275,8 +6264,7 @@ public final class ActivityThread extends ClientTransactionHandler
                if (!mInstrumentation.onException(r.activity, e)) {
                    throw new RuntimeException(
                            "Unable to pause activity "
                            + r.intent.getComponent().toShortString()
                            + ": " + e.toString(), e);
                            + r.intent.getComponent().toShortString(), e);
                }
            }
        }
@@ -6308,7 +6296,7 @@ public final class ActivityThread extends ClientTransactionHandler
            } catch (Exception e) {
                if (!mInstrumentation.onException(r.activity, e)) {
                    throw new RuntimeException("Unable to retain activity "
                            + r.intent.getComponent().toShortString() + ": " + e.toString(), e);
                            + r.intent.getComponent().toShortString(), e);
                }
            }
        }
@@ -6327,7 +6315,7 @@ public final class ActivityThread extends ClientTransactionHandler
        } catch (Exception e) {
            if (!mInstrumentation.onException(r.activity, e)) {
                throw new RuntimeException("Unable to destroy activity "
                        + safeToComponentShortString(r.intent) + ": " + e.toString(), e);
                        + safeToComponentShortString(r.intent), e);
            }
        }
        r.setState(ON_DESTROY);
@@ -7899,8 +7887,7 @@ public final class ActivityThread extends ClientTransactionHandler
            }
            catch (Exception e) {
                throw new RuntimeException(
                    "Exception thrown in onCreate() of "
                    + data.instrumentationName + ": " + e.toString(), e);
                    "Exception thrown in onCreate() of " + data.instrumentationName, e);
            }
            try {
                timestampApplicationOnCreateNs = SystemClock.uptimeNanos();
@@ -7909,8 +7896,7 @@ public final class ActivityThread extends ClientTransactionHandler
                timestampApplicationOnCreateNs = 0;
                if (!mInstrumentation.onException(app, e)) {
                    throw new RuntimeException(
                      "Unable to create application " + app.getClass().getName()
                      + ": " + e.toString(), e);
                      "Unable to create application " + app.getClass().getName(), e);
                }
            }
        } finally {
@@ -8081,8 +8067,7 @@ public final class ActivityThread extends ClientTransactionHandler
                mInstrumentation.onCreate(data.instrumentationArgs);
            } catch (Exception e) {
                throw new RuntimeException(
                        "Exception thrown in onCreate() of "
                                + data.instrumentationName + ": " + e.toString(), e);
                        "Exception thrown in onCreate() of " + data.instrumentationName, e);
            }

        } catch (Exception e) {
@@ -8159,8 +8144,7 @@ public final class ActivityThread extends ClientTransactionHandler
                    cl.loadClass(data.instrumentationName.getClassName()).newInstance();
        } catch (Exception e) {
            throw new RuntimeException(
                    "Unable to instantiate instrumentation "
                            + data.instrumentationName + ": " + e.toString(), e);
                    "Unable to instantiate instrumentation " + data.instrumentationName, e);
        }

        final ComponentName component = new ComponentName(ii.packageName, ii.name);
@@ -8742,8 +8726,7 @@ public final class ActivityThread extends ClientTransactionHandler
            } catch (java.lang.Exception e) {
                if (!mInstrumentation.onException(null, e)) {
                    throw new RuntimeException(
                            "Unable to get provider " + info.name
                            + ": " + e.toString(), e);
                            "Unable to get provider " + info.name, e);
                }
                return null;
            }
@@ -8913,7 +8896,7 @@ public final class ActivityThread extends ClientTransactionHandler
            thread.mInitialApplication = context.mPackageInfo.makeApplicationInner(true, null);
            thread.mInitialApplication.onCreate();
        } catch (Exception e) {
            throw new RuntimeException("Unable to instantiate Application():" + e, e);
            throw new RuntimeException("Unable to instantiate Application()", e);
        }
    }

+4 −4
Original line number Diff line number Diff line
@@ -705,7 +705,7 @@ class ContextImpl extends Context {
                    res++;
                }
            } catch (IOException e) {
                Log.w(TAG, "Failed to migrate " + sourceFile + ": " + e);
                Log.w(TAG, "Failed to migrate " + sourceFile, e);
                res = -1;
            }
        }
@@ -821,7 +821,7 @@ class ContextImpl extends Context {
                if (e.errno == OsConstants.EEXIST) {
                    // We must have raced with someone; that's okay
                } else {
                    Log.w(TAG, "Failed to ensure " + file + ": " + e.getMessage());
                    Log.w(TAG, "Failed to ensure " + file, e);
                }
            }

@@ -832,7 +832,7 @@ class ContextImpl extends Context {
                    Memory.pokeLong(value, 0, stat.st_ino, ByteOrder.nativeOrder());
                    Os.setxattr(file.getParentFile().getAbsolutePath(), xattr, value, 0);
                } catch (ErrnoException e) {
                    Log.w(TAG, "Failed to update " + xattr + ": " + e.getMessage());
                    Log.w(TAG, "Failed to update " + xattr, e);
                }
            }
        }
@@ -3768,7 +3768,7 @@ class ContextImpl extends Context {
                        }
                    }
                } catch (Exception e) {
                    Log.w(TAG, "Failed to ensure " + dir + ": " + e);
                    Log.w(TAG, "Failed to ensure " + dir, e);
                    dir = null;
                }
            }
+2 −3
Original line number Diff line number Diff line
@@ -1488,7 +1488,7 @@ public final class LoadedApk {
                if (!mActivityThread.mInstrumentation.onException(app, e)) {
                    throw new RuntimeException(
                        "Unable to instantiate application " + appClass
                        + " package " + mPackageName + ": " + e.toString(), e);
                        + " package " + mPackageName, e);
                }
            }
            mActivityThread.addApplication(app);
@@ -1505,8 +1505,7 @@ public final class LoadedApk {
                } catch (Exception e) {
                    if (!instrumentation.onException(app, e)) {
                        throw new RuntimeException(
                            "Unable to create application " + app.getClass().getName()
                            + ": " + e.toString(), e);
                            "Unable to create application " + app.getClass().getName(), e);
                    }
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -499,7 +499,7 @@ public class ClipData implements Parcelable {
            try {
                resolver = context.getContentResolver();
            } catch (Exception e) {
                Log.w(TAG, "Failed to obtain ContentResolver: " + e);
                Log.w(TAG, "Failed to obtain ContentResolver", e);
            }

            // If this Item has a URI value, try using that.
+2 −2
Original line number Diff line number Diff line
@@ -944,7 +944,7 @@ public abstract class ContentResolver implements ContentInterface {
                // Manager will kill this process shortly anyway.
                return null;
            } catch (java.lang.Exception e) {
                Log.w(TAG, "Failed to get type for: " + url + " (" + e.getMessage() + ")");
                Log.w(TAG, "Failed to get type for: " + url, e);
                return null;
            } finally {
                try {
@@ -974,7 +974,7 @@ public abstract class ContentResolver implements ContentInterface {
            // We just failed to send a oneway request to the System Server. Nothing to do.
            return null;
        } catch (java.lang.Exception e) {
            Log.w(TAG, "Failed to get type for: " + url + " (" + e.getMessage() + ")");
            Log.w(TAG, "Failed to get type for: " + url, e);
            return null;
        }
    }
Loading