Something like this may be even better, since you should probably allow the original functionality except whatever you’re trying to change:
protected virtual void _(Events.RowDeleting<POLine> e, PXRowDeleting b)
{
POLine row = e.Row;
try
{
b?.Invoke(e.Cache, e.Args);
}
catch (PXException ex)
{
// Check if ex.Message is the one you're trying to avoid and allow it through if NOT
if (ex.Message != PX.Objects.PO.Messages.POOrderLineHasReceiptsAndCannotBeDeleted)
{
throw ex;
}
else // If it is the one you're trying to avoid, allow the delete
e.Cancel = false;
}
}