These are guidelines related to the development of Confluence. The guidelines mainly apply to Atlassian employees, but reading them should provide insight for third-party plugin developers as well, so we decided to make them public.
Randomly sorted guidelines.
Exception unless that's all you're having thrown to you.Exception ever.RuntimeException as well.Throwable if you want to continue breathing.Error and any subclasses of Error as well.NullPointerException?@throws Javadoc like you would a checked exception.Where possible create, document and throw meaningful unchecked exceptions. For example, write this:
1 2public class MyGroupManager { /** * ... * @throws InvalidGroupException if the group cannot be handled */ public void handleGroup(Group group) throws InvalidGroupException { if (!isValidGroup(group)) throw new InvalidGroupException("Group is invalid: " + group.toString()); // do something with the group } } public class InvalidGroupException extends RuntimeException { // ... }
In preference to this:
1 2public class EvilGroupManager { public void handleGroup(Group group) { if (!isValidGroup(group)) throw new RuntimeException("Group is invalid: " + group.toString()); // do something with the group } }
The latter implementation is not as good because it gives the calling code very little discretion as to what kind of exceptions it wants to handle.
Rate this page: