Bug 492238

Summary: Exceptions need refactoring
Product: [Community] Spacewalk Reporter: Jesus M. Rodriguez <jesusr>
Component: WebUIAssignee: Brad Buckingham <bbuckingham>
Status: CLOSED WONTFIX QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: low    
Version: 0.6CC: cperry, jesusr, mmccune
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-05-25 15:08:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 585232    

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;
  }