/// <summary> /// Create a generic conflict. /// </summary> /// <param name="e"></param> /// <param name="group"></param> /// <returns></returns> private ConflictResolutionResult createGenericConflict(Exception e, ChangeGroup group) { Debug.Assert(e != null, "Exception e for creating generic conflict is NULL"); Debug.Assert(group != null, "Conflicted change group is NULL"); Debug.Assert(m_conflictManagementService != null, "ConflictManager is not properly initialized"); MigrationConflict genericConflict = GenericConflictType.CreateConflict(e); List <MigrationAction> retActions; ConflictResolutionResult resolutionResult = m_conflictManagementService.TryResolveNewConflict(group.SourceId, genericConflict, out retActions); return(resolutionResult); }
/// <summary> /// Try handling an exception /// </summary> /// <param name="e"></param> /// <param name="conflictManager"></param> /// <returns>The decision returned is either RoutedAsError or RaisedAsRuntimeConflict</returns> public ErrorHandlingResult TryHandleException(Exception e, ConflictManager conflictManager) { bool conflictManagementIsEnabled = (null != conflictManager); bool anErrorRouterIsFound = false; bool exceptionIsRoutedAsError = false; foreach (ErrorRouter errRouter in m_errRegService.RegisteredRouters) { ErrorHandlingResult rslt = errRouter.TryRouteError(e, this.m_routingChannels.AsReadOnly()); switch (rslt.Decision) { case ErrorHandlingResult.RoutingDecision.RaisedAsRuntimeConflict: anErrorRouterIsFound = true; exceptionIsRoutedAsError = true; break; case ErrorHandlingResult.RoutingDecision.PolicyConditionIsNotMet: anErrorRouterIsFound = true; break; case ErrorHandlingResult.RoutingDecision.RoutedAsError: return(rslt); default: break; } if (anErrorRouterIsFound || exceptionIsRoutedAsError) { break; } } if (exceptionIsRoutedAsError) { return(new ErrorHandlingResult(ErrorHandlingResult.RoutingDecision.RoutedAsError)); } if (conflictManagementIsEnabled) { MigrationConflict conflict = GenericConflictType.CreateConflict(e); List <MigrationAction> actions; conflictManager.TryResolveNewConflict(conflictManager.SourceId, conflict, out actions); return(new ErrorHandlingResult(ErrorHandlingResult.RoutingDecision.RaisedAsRuntimeConflict)); } else if (anErrorRouterIsFound) { // no conflict manager to log the runtime conflict throw new MissingErrorRouterException( "Runtime error does not meet the error routine policy and there is no conflict manager to log a conflict.", e); } else { // no conflict manager is present to raise the error as a runtime conflict // - default to report as an error foreach (IErrorRoutingChannel channel in m_routingChannels) { channel.RouteError(e); } return(new ErrorHandlingResult(ErrorHandlingResult.RoutingDecision.RoutedAsError)); } }