public override Exception ProcessResult(int resultCode, Guid id, object loadedInstance) { Exception toReturn = null; switch (resultCode) { case 0: // Success break; case 1: // Instance not found toReturn = new InstanceNotFoundException(id); break; case 2: // Could not acquire lock toReturn = new InstanceLockException(id); break; default: toReturn = new PersistenceException(SR2.GetString(SR2.UnknownStoredProcResult)); break; } if (toReturn == null) { if (loadedInstance == null) { toReturn = new PersistenceException(SR2.GetString(SR2.SerializationFormatMismatch)); } } return toReturn; }
void ScheduledCallback(object state) { Exception completionException = null; try { this.provider.PerformOpen(this.timeout); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completionException = new PersistenceException( SR2.GetString(SR2.ErrorOpeningSqlPersistenceProvider), e); } Complete(false, completionException); }
static void CommandExecutionComplete(IAsyncResult result) { if (result.CompletedSynchronously) { return; } OperationAsyncResult operationResult = (OperationAsyncResult)result.AsyncState; Exception completionException = null; try { completionException = operationResult.CompleteOperation(result); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } completionException = new PersistenceException( SR2.GetString(SR2.PersistenceOperationError, operationResult.handler.OperationName), e); } finally { try { operationResult.command.Connection.Close(); operationResult.provider.CleanupCommand(operationResult.command); } catch (Exception e1) { if (Fx.IsFatal(e1)) { throw; } // do not rethrow non-fatal exceptions thrown from cleanup code } } operationResult.Complete(false, completionException); }