Skip to content

Generating Exception Id number in Intellij IDEA with Live Templates

Krzysztof Suszyński edited this page Oct 27, 2018 · 5 revisions

To add ability to generate Eid in Intellij IDEA, you can use Live Templates.

  1. Go to File > Settings > Editor > Live Templates
  2. Inside section plain, add (button +) new Live Template
  3. Name newly created template, simply, 'e' (Abbreviation field), and paste description as Exception ID (Eid)
  4. Set scope to Java > String (this makes auto completion only active inside String literal) and JavaScript > Other.
  5. In Template Text field put simply: $EID$
  6. Click edit variables
  7. Paste date("yyyyMMdd:HHmmss") into expression

That's it. Now inside your code write e character into String literal, and hit Tab:

throw new EidRuntimeException("e");

After hitting Tab key