Skip to content

Commit 4de06d1

Browse files
shai-almogclaude
andcommitted
fix(js-port-diag): make Log.edtErr instrumentation lint-clean
The bindCrashProtection diagnostic added in e600713 used inline ``try { ... } catch (...) { ... }`` and trailing-em-dash comments — which trip Checkstyle's LeftCurly/RightCurly rules in the build-test matrix and US-ASCII javac in the Android Ant port build. Reformat the try/catch ladders to standard multi-line form and replace ``—`` with ``--`` in the prose so the diagnostic stays in place but stops failing the matrix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 364c239 commit 4de06d1

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

  • CodenameOne/src/com/codename1/io

CodenameOne/src/com/codename1/io/Log.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,14 @@ public void actionPerformed(ActionEvent evt) {
391391
// TEMPORARY DIAGNOSTIC INSTRUMENTATION (PR #4795): the ParparVM
392392
// JS port currently surfaces every original EDT exception as a
393393
// bare ``Exception: <class>`` line because *this* listener
394-
// throws an NPE while trying to format the report the
394+
// throws an NPE while trying to format the report -- the
395395
// formatting NPE is the one that ends up logged, the original
396396
// is silently swallowed. Wrap each step so we can identify
397397
// which sub-call fails AND so the caught ``evt.getSource()``
398398
// throwable still reaches ``Log.e`` even when a preceding
399399
// line dies. Use ``Log.p(s, 1)`` (level=INFO) for the
400400
// markers so they survive the JS port's
401-
// ``console.error``-only echo path the worker-side
401+
// ``console.error``-only echo path -- the worker-side
402402
// ``System.out.println`` route is gated behind the
403403
// ``?parparDiag=1`` flag and gets dropped on the live
404404
// preview. Remove this granular wrapping once the JS-port
@@ -412,37 +412,52 @@ public void actionPerformed(ActionEvent evt) {
412412
p("[edtErr] getSource threw: " + t, 1);
413413
}
414414
if (consumeError) {
415-
try { evt.consume(); }
416-
catch (Throwable t) { p("[edtErr] consume threw: " + t, 1); }
415+
try {
416+
evt.consume();
417+
} catch (Throwable t) {
418+
p("[edtErr] consume threw: " + t, 1);
419+
}
417420
}
418421
try {
419422
p("Exception in " + Display.getInstance().getProperty("AppName", "app") + " version " + Display.getInstance().getProperty("AppVersion", "Unknown"));
420-
} catch (Throwable t) { p("[edtErr] appName/version threw: " + t, 1); }
423+
} catch (Throwable t) {
424+
p("[edtErr] appName/version threw: " + t, 1);
425+
}
421426
try {
422427
p("OS " + Display.getInstance().getPlatformName());
423-
} catch (Throwable t) { p("[edtErr] platformName threw: " + t, 1); }
428+
} catch (Throwable t) {
429+
p("[edtErr] platformName threw: " + t, 1);
430+
}
424431
try {
425432
p("Error " + source);
426-
} catch (Throwable t) { p("[edtErr] sourceLog threw: " + t, 1); }
433+
} catch (Throwable t) {
434+
p("[edtErr] sourceLog threw: " + t, 1);
435+
}
427436
try {
428437
if (Display.getInstance().getCurrent() != null) {
429438
p("Current Form " + Display.getInstance().getCurrent().getName());
430439
} else {
431440
p("Before the first form!");
432441
}
433-
} catch (Throwable t) { p("[edtErr] currentForm threw: " + t, 1); }
442+
} catch (Throwable t) {
443+
p("[edtErr] currentForm threw: " + t, 1);
444+
}
434445
try {
435446
if (source instanceof Throwable) {
436447
e((Throwable) source);
437448
} else {
438449
p("[edtErr] source not Throwable, skipping Log.e", 1);
439450
}
440-
} catch (Throwable t) { p("[edtErr] Log.e threw: " + t, 1); }
451+
} catch (Throwable t) {
452+
p("[edtErr] Log.e threw: " + t, 1);
453+
}
441454
try {
442455
if (getUniqueDeviceKey() != null) {
443456
sendLog();
444457
}
445-
} catch (Throwable t) { p("[edtErr] sendLog threw: " + t, 1); }
458+
} catch (Throwable t) {
459+
p("[edtErr] sendLog threw: " + t, 1);
460+
}
446461
p("[edtErr] exit listener", 1);
447462
}
448463
});

0 commit comments

Comments
 (0)