Skip to content

Instantly share code, notes, and snippets.

@tkfx
Created July 5, 2016 10:55
Show Gist options
  • Select an option

  • Save tkfx/cc74e99e42886c87589ed186bdad7dcf to your computer and use it in GitHub Desktop.

Select an option

Save tkfx/cc74e99e42886c87589ed186bdad7dcf to your computer and use it in GitHub Desktop.
// Bad.
// - Line breaks are arbitrary.
// - Scanning the code makes it difficult to piece the message together.
throw new IllegalStateException("Failed to process request" + request.getId()
+ " for user " + user.getId() + " query: '" + query.getText()
+ "'");
// Good.
// - Each component of the message is separate and self-contained.
// - Adding or removing a component of the message requires minimal reformatting.
throw new IllegalStateException("Failed to process"
+ " request " + request.getId()
+ " for user " + user.getId()
+ " query: '" + query.getText() + "'");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment