Bug 492238 - Exceptions need refactoring
Summary: Exceptions need refactoring
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Spacewalk
Classification: Community
Component: WebUI
Version: 0.6
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Brad Buckingham
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space11
TreeView+ depends on / blocked
 
Reported: 2009-03-26 02:43 UTC by Jesus M. Rodriguez
Modified: 2010-05-25 15:08 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-05-25 15:08:26 UTC
Embargoed:


Attachments (Terms of Use)

Description Jesus M. Rodriguez 2009-03-26 02:43:49 UTC
This is more of a note to self, but I'd figured I'd share with everyone.
We need to revisit our exception classes, the api has a very rich set
of exceptions that can be useful by other parts of the code.

Most folks don't want to use them because they live in an xmlrpc 
package, and we could probably move them to a more common location.
Another reason is not all of the api exceptions are localized (usually
the older ones).

Another thing I noticed was that the exceptions that are localized
none of them use the FaultExceptions constructor which accepts the
localized parameters:

  public FaultException(int error, String lbl, String messageId, Object [] args) {
    super(LocalizationService.getInstance().getMessage(messageId, args));
    this.errorCode =  error;
    this.label =  lbl;
  } 

We seem to do it the hardway :)

  ...
  super(1062, "Invalid Arch" , LocalizationService.getInstance().
          getMessage("api.system.invalidarch", new Object [] {arch}));

This could've been easily written as:

  super(1062, "Invalid Arch", "api.system.invalidarch", new Object [] {arch}));

Honestly, I would do away with the messageid altogether and use
the exception label as the messageid. So the ctor would change to:

  super(1062, "Invalid Arch", new Object [] {arch}));

And in FaultException (top example) it would change to this:

  public FaultException(int error, String lbl, Object [] args) {
    super(LocalizationService.getInstance().getMessage(lbl, args));
    this.errorCode =  error;
    this.label =  lbl;
  }


Note You need to log in before you can comment on or make changes to this bug.