Skip to content

Instantly share code, notes, and snippets.

@matzew
Created February 6, 2018 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/78a68d8ef69e2790dd6fc50c5d3308ab to your computer and use it in GitHub Desktop.
Save matzew/78a68d8ef69e2790dd6fc50c5d3308ab to your computer and use it in GitHub Desktop.

One option:

... // somewhere inside a method...
final ApnsClient apnsClient;
{
  try {
    apnsClient = receiveApnsConnection(...);
  } catch (IllegalArgumentException iae) {
    logger.error(iae.getMessage(), iae);
    senderCallback.onError(String.format("Unable to connect to APNs (%s))", iae.getMessage()));
    return; // adios !
  }
}

versus this one:

... // in some methods....
final ApnsClient apnsClient;
try {
  apnsClient = receiveApnsConnection(...);
} catch (IllegalArgumentException iae) {
  logger.error(iae.getMessage(), iae);
  senderCallback.onError(String.format("Unable to connect to APNs (%s))", iae.getMessage()));
  return; // adios!
}

for some reason I do find the first one a bit more readable, due to the strcuted {} block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment