Bug 492238 - Exceptions need refactoring
Exceptions need refactoring
Status: CLOSED WONTFIX
Product: Spacewalk
Classification: Community
Component: WebUI (Show other bugs)
0.6
All Linux
low Severity medium
: ---
: ---
Assigned To: Brad Buckingham
Red Hat Satellite QA List
:
Depends On:
Blocks: space11
  Show dependency treegraph
 
Reported: 2009-03-25 22:43 EDT by Jesus M. Rodriguez
Modified: 2010-05-25 11:08 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-05-25 11:08:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jesus M. Rodriguez 2009-03-25 22:43:49 EDT
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.