Blog

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Image AddedThe Java library smartics

...

exception has been released with version 0.10.0.

This library allows to design exceptions in your application and to generate reports on the error codes. The exceptioncodes-maven-plugin generates exception codes reports and has also been released to match the new features of smartics-exceptions.

One major change is the inclusion of ICU's MessageFormat. Now it is possible to use telling names for place holders instead of the numeric indices required by Java's message format class.

Code Block
languagejava

...

@ParentMessageParam("cause=0:message")

...


public class MyException extends BaseException {

...


  @MessageParam("2:host,3:port")

...


  private final URL url;
Code Block
language

...

java

...

@ParentMessageParam("cause=0:message")

...


public class BaseException extends AbstractLocalizedRuntimeException {

...


  @MessageParam("1")

...


  private final String name;

...

You may now do this:

...

Code Block
languagejava
public class MyException extends BaseException {

...


  @MessageParam(":host,:port")

...


  private final URL url;
Code Block

...

languagejava

...

@ParentMessageParam("cause=causeMessage:message")

...


public class BaseException extends AbstractLocalizedRuntimeException {

...


  @MessageParam

...


  private final String name;

...

This will make it much easier if you add new properties to the base class later.

The message bundles will also be easier to read. The indexed version:

...

Code Block
1000=The name is set to {1}. URL is ''{2}:{3}'': {0}

...

The new version with property names:

Code Block

...

1000=The name is set to {name}. URL is ''{host}:{port}'': {causeMessage}

...

Thanks to ICU the composed messages are now also easier to handle:

...

Code Block
languagejava
  /**

...


   * Count of faults.

...


   *

...


   * @serial

...


   */

...


  @MessageParam

...


  private final int faultCount;

...

Code Block

...

1001=The service has encountered {faultCount,plural,\

...


  =0{no faults}\

...


  =1{one fault}\

...


  other{# faults}\

...


 }.

...

 

Instead of our old proprietary format:

Code Block

...

1001=The service has encountered {0}.

...


1001.0.0=no faults

...


1001.0.1=one fault

...


1001.0.m={0} faults

...

For more new message format features provided by

...

ICU’s message format, please refer to their API documentation.

For details on this library please visit the

...

project’s homepage, for changes since the last version, please consult the release report.