[Pki-devel] Fixes exception while invalid module.

Endi Sukma Dewata edewata at redhat.com
Tue Jun 28 17:54:55 UTC 2016


On 6/21/2016 3:19 AM, Amol Kahat wrote:
> Hi,
>
> Please review this patch.
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1348446
>
> Thanks
> Amol K

I think to fix this problem properly the code should raise a 
CLIException (needs to be added) if it cannot find the module, then the 
main program should catch the exception and print the proper error 
message (and stack trace in verbose mode).

See the code at the bottom of these files:
* base/java-tools/bin/pki
* base/server/sbin/pki-server

I think those files should be changed into something like this:

     try:
         cli.execute(sys.argv)

     except subprocess.CalledProcessError as e:
         if cli.verbose:
             traceback.print_exc()
         print('ERROR: %s' % e)
         exit(e.returncode)

     except pki.cli.CLIException as e:
         if cli.verbose:
             traceback.print_exc()
         print('ERROR: %s' % e)
         exit(1)

-- 
Endi S. Dewata




More information about the Pki-devel mailing list