Closed anthrotype closed 7 years ago
@typemytype shall I tag and publish v0.6.0 with the new custom exceptions?
Yes please Thanks
On Monday, 17 October 2016, Cosimo Lupo notifications@github.com wrote:
@typemytype https://github.com/typemytype shall I tag and publish v0.6.0 with the new custom exceptions?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/typemytype/booleanOperations/pull/37#issuecomment-254315429, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIp1ll7CsXvX68RYkj59ZYjpAJ5boN4ks5q09MVgaJpZM4KYifW .
gr Frederik www.typemytype.com
When an invalid contour is received as a subject or clipping path,
pyclipper
raises its ownClipperException
error.I wouldn't want clients to have to import pyclipper in order to handle the exception. I believe that should stay private as we may decide to replace pyclipper with another implementation in the future.
So we need to define our own custom exceptions, and re-raise the
pyclipper.ClipperException
asbooleanOperations.BooleanOperationsError
.For example, one could do:
The custom errors are defined in the
booleanOperations.exceptions
module. For convenience, the generic one is also exported in the top-level module asbooleanOperations.BooleanOperationsError
.Note that previously, we were calling pyclipper's
AddPaths
method, which only raised when all the input path are invalid; I replaced it withAddPath
(in a loop), so we can raise when any input path is invalid, and report which one in the exception message, so the user can find it more easily.