Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 2328 - proper error handling in portage (python exceptions)
Summary: proper error handling in portage (python exceptions)
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: x86 All
: High enhancement
Assignee: Portage team
URL:
Whiteboard:
Keywords:
: 2410 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-05-02 01:51 UTC by George Shapovalov (RETIRED)
Modified: 2011-10-30 22:21 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
portage exceptions module (portage_exceptions.py,1.35 KB, application/octet-stream)
2002-05-02 01:52 UTC, George Shapovalov (RETIRED)
Details
a fix to emerge to comment out "broken" world entries (emerge.patch,1.87 KB, patch)
2002-05-03 23:01 UTC, George Shapovalov (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description George Shapovalov (RETIRED) gentoo-dev 2002-05-02 01:51:09 UTC
I would like to propose proper mechanism for error handling in portage. It is
very natural to use exceptions instead of 
print "I am doing harakiri now ;)"
sys.exit(1)
as done now.
This will resolve situations when certain problematic situation catched deep
inside some method has to be dealt with differently based on where it was called
(like emerge system vs world...). Case in hand: bug #1841.

I created module portage_exceptions.py to introduce such functionality. It
contains basic PortageError class with virtual methods handle and report. and
GenericPortageError, which imitates p[resent portage behavior:
handle will output error message and halt, while report will only output message.

In order to gracefully report a problem instead of printing a traceback, the
module defines and hooks generic exception handler (which just calls handle of
corresponding exception). Thus the default behaviour in case of a problem
imitates the one at present (which is hardwired now). The advantage is that with
exceptions it is possible to override it whenever necessary.

It is very easy to modify exicting sources to make use of this mechanism:
just replace occurencies of
print ErrorMessage sys.exit(1)
with raise GenericPortageError(ErrorMessage)
and that's it! (don't forget to import portage_exceptions of course).

In case you need somewhat different error reporting functionality, derive new
exception from either basic or generic one and override appropriate method (most
likely that will be "handle").
Please see sources for more details.

George
Comment 1 George Shapovalov (RETIRED) gentoo-dev 2002-05-02 01:52:20 UTC
Created attachment 756 [details]
portage exceptions module
Comment 2 George Shapovalov (RETIRED) gentoo-dev 2002-05-03 23:01:50 UTC
Created attachment 814 [details, diff]
a fix to emerge to comment out "broken" world entries

this is a complimentary fix from 1841,
adding here per Daniel's request since it #1841 was closed.
This patch will scan world entries before checking dependencies when doing 
emerge --update world
and comment out problematic entries. 
Uses introduced exception mechanism.
should apply against emerge-1.90
Comment 3 SpanKY gentoo-dev 2002-10-30 00:05:53 UTC
*** Bug 2410 has been marked as a duplicate of this bug. ***
Comment 4 Heinrich Wendel (RETIRED) gentoo-dev 2003-11-19 06:20:52 UTC
i don't think this will still apply, if this is still an issue open a new bug