public ArgumentException(string?message, Exception?innerException) : base(message, innerException) { HResult = HResults.COR_E_ARGUMENT; }
public MissingConfigurationException(string message, Exception?innerException) : base(message, innerException) { }
public Builder WithException(Exception exception) { _exception = exception; return(this); }
/// <summary> /// Initializes a new instance of <see cref="InvalidConfigurationException"/>. /// </summary> /// <param name="message">The message of the exception (optional).</param> /// <param name="innerException">The exception that is the cause of this one (optional).</param> public InvalidConfigurationException(string?message = null, Exception?innerException = null) : base(message, innerException) { }
public JavaScriptException(JavaScriptException exception, Exception?innerException) : base(exception.Message, exception.InnerException) { Error = exception.Error; Location = exception.Location; }
public static extern void FailFast(string?message, Exception?exception, string?errorMessage);
public ReminderBuilderException(string?message, Exception?innerException) : base(message, innerException) { }
protected override Task <RunSummary> RunTestClassAsync(_ITestClass testClass, _IReflectionTypeInfo @class, IEnumerable <IXunitTestCase> testCases) { RunTestClassAsync_AggregatorResult = Aggregator.ToException(); return(Task.FromResult(new RunSummary())); }
public ObjectDisposedException(string?message, Exception?innerException) : base(message, innerException) { HResult = HResults.COR_E_OBJECTDISPOSED; }
public TypeUnloadedException(string?message, Exception?innerException) : base(message, innerException) { HResult = HResults.COR_E_TYPEUNLOADED; }
public AssertActualExpectedException(object?expected, object?actual, string?userMessage, string?expectedTitle, string?actualTitle, Exception?innerException)
/// <summary> /// Initializes a new instance of the <see cref="BarrierPostPhaseException"/> class with a specified error message and inner exception. /// </summary> /// <param name="message">A string that describes the exception.</param> /// <param name="innerException">The exception that is the cause of the current exception.</param> public BarrierPostPhaseException(string?message, Exception?innerException) : base(message == null ? SR.BarrierPostPhaseException : message, innerException) { }
/// <summary> /// Initializes a new instance of the <see cref="BarrierPostPhaseException"/> class with the specified inner exception. /// </summary> /// <param name="innerException">The exception that is the cause of the current exception.</param> public BarrierPostPhaseException(Exception?innerException) : this(null, innerException) { }
public ArgumentException(string?message, string?paramName, Exception?innerException) : base(message, innerException) { _paramName = paramName; HResult = HResults.COR_E_ARGUMENT; }
public FrameworkException(string?message, Exception?innerException) : base(message, innerException) { }
public ControlPanelWebApiClientAddModuleAsyncOperationException(string?message, Exception?innerException) : base(message, innerException) { }
public static extern void FailFast(string?message, Exception?exception);
private static Exception CreateFileNotFoundException(string fileName, Exception?inner) { return(new FileNotFoundException(null, fileName, inner)); }
public AnalyzerLoadFailureEventArgs(FailureErrorCode errorCode, string message, Exception?exceptionOpt = null, string?typeNameOpt = null) { if (errorCode <= FailureErrorCode.None || errorCode > FailureErrorCode.ReferencesFramework) { throw new ArgumentOutOfRangeException(nameof(errorCode)); } if (message == null) { throw new ArgumentNullException(nameof(message)); } ErrorCode = errorCode; Message = message; TypeName = typeNameOpt; Exception = exceptionOpt; }
public ITrackerFaultedEvent CreateTrackerFaultedEvent(Guid scopeId, Guid trackerId, DateTimeOffset timestamp, TimeSpan elapsed, Exception?exception) => new TrackerFaultedEvent(scopeId, trackerId, timestamp, elapsed, exception);
public override void Complete(Exception?exception = null) { _inner.Complete(exception); ReturnBuffer(); }
/// <inheritdoc /> public override async Task <InputFormatterResult> ReadRequestBodyAsync( InputFormatterContext context, Encoding encoding) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (encoding == null) { throw new ArgumentNullException(nameof(encoding)); } var httpContext = context.HttpContext; var request = httpContext.Request; var suppressInputFormatterBuffering = _options.SuppressInputFormatterBuffering; var readStream = request.Body; var disposeReadStream = false; if (readStream.CanSeek) { // The most common way of getting here is the user has request buffering on. // However, request buffering isn't eager, and consequently it will peform pass-thru synchronous // reads as part of the deserialization. // To avoid this, drain and reset the stream. var position = request.Body.Position; await readStream.DrainAsync(CancellationToken.None); readStream.Position = position; } else if (!suppressInputFormatterBuffering) { // JSON.Net does synchronous reads. In order to avoid blocking on the stream, we asynchronously // read everything into a buffer, and then seek back to the beginning. var memoryThreshold = _jsonOptions.InputFormatterMemoryBufferThreshold; var contentLength = request.ContentLength.GetValueOrDefault(); if (contentLength > 0 && contentLength < memoryThreshold) { // If the Content-Length is known and is smaller than the default buffer size, use it. memoryThreshold = (int)contentLength; } readStream = new FileBufferingReadStream(request.Body, memoryThreshold); // Ensure the file buffer stream is always disposed at the end of a request. httpContext.Response.RegisterForDispose(readStream); await readStream.DrainAsync(CancellationToken.None); readStream.Seek(0L, SeekOrigin.Begin); disposeReadStream = true; } var successful = true; Exception?exception = null; object model; using (var streamReader = context.ReaderFactory(readStream, encoding)) { using var jsonReader = new JsonTextReader(streamReader); jsonReader.ArrayPool = _charPool; jsonReader.CloseInput = false; var type = context.ModelType; var jsonSerializer = CreateJsonSerializer(context); jsonSerializer.Error += ErrorHandler; if (_jsonOptions.ReadJsonWithRequestCulture) { jsonSerializer.Culture = CultureInfo.CurrentCulture; } try { model = jsonSerializer.Deserialize(jsonReader, type); } finally { // Clean up the error handler since CreateJsonSerializer() pools instances. jsonSerializer.Error -= ErrorHandler; ReleaseJsonSerializer(jsonSerializer); if (disposeReadStream) { await readStream.DisposeAsync(); } } } if (successful) { if (model == null && !context.TreatEmptyInputAsDefaultValue) { // Some nonempty inputs might deserialize as null, for example whitespace, // or the JSON-encoded value "null". The upstream BodyModelBinder needs to // be notified that we don't regard this as a real input so it can register // a model binding error. return(InputFormatterResult.NoValue()); } else { return(InputFormatterResult.Success(model)); } } if (exception is not null && exception is not(JsonException or OverflowException or FormatException)) { // At this point we've already recorded all exceptions as an entry in the ModelStateDictionary. // We only need to rethrow an exception if we believe it needs to be handled by something further up // the stack. // JsonException, OverflowException, and FormatException are assumed to be only encountered when // parsing the JSON and are consequently "safe" to be exposed as part of ModelState. Everything else // needs to be rethrown. var exceptionDispatchInfo = ExceptionDispatchInfo.Capture(exception); exceptionDispatchInfo.Throw(); } return(InputFormatterResult.Failure()); void ErrorHandler(object?sender, Newtonsoft.Json.Serialization.ErrorEventArgs eventArgs) { successful = false; // When ErrorContext.Path does not include ErrorContext.Member, add Member to form full path. var path = eventArgs.ErrorContext.Path; var member = eventArgs.ErrorContext.Member?.ToString(); var addMember = !string.IsNullOrEmpty(member); if (addMember) { // Path.Member case (path.Length < member.Length) needs no further checks. if (path.Length == member !.Length) { // Add Member in Path.Memb case but not for Path.Path. addMember = !string.Equals(path, member, StringComparison.Ordinal); } else if (path.Length > member.Length) { // Finally, check whether Path already ends with Member. if (member[0] == '[') { addMember = !path.EndsWith(member, StringComparison.Ordinal); } else { addMember = !path.EndsWith("." + member, StringComparison.Ordinal) && !path.EndsWith("['" + member + "']", StringComparison.Ordinal) && !path.EndsWith("[" + member + "]", StringComparison.Ordinal); } } } if (addMember) { path = ModelNames.CreatePropertyModelName(path, member); } // Handle path combinations such as ""+"Property", "Parent"+"Property", or "Parent"+"[12]". var key = ModelNames.CreatePropertyModelName(context.ModelName, path); exception = eventArgs.ErrorContext.Error; var metadata = GetPathMetadata(context.Metadata, path); var modelStateException = WrapExceptionForModelState(exception); context.ModelState.TryAddModelError(key, modelStateException, metadata); _logger.JsonInputException(exception); // Error must always be marked as handled // Failure to do so can cause the exception to be rethrown at every recursive level and // overflow the stack for x64 CLR processes eventArgs.ErrorContext.Handled = true; }
public JavaScriptException(ErrorConstructor errorConstructor, string?message, Exception?innerException) : base(message, innerException) { Error = errorConstructor.Construct(new JsValue[] { message }); }
/// <summary>Tries to remove a value.</summary> /// <param name="stepper">The relative keys of the value.</param> /// <param name="exception">The exception that occurred if the remove failed.</param> /// <returns>True if the remove was successful or false if not.</returns> public bool TryRemove(Action <Action <T> > stepper, out Exception?exception) { if (stepper is null) { exception = new ArgumentNullException(nameof(stepper)); return(false); } IStack <(T, MapHashLinked <Node, T>, Node)> pathStack = new StackLinked <(T, MapHashLinked <Node, T>, Node)>(); T finalKey = default; MapHashLinked <Node, T>?finalMap = null; Node? node = null; Exception?capturedException = null; stepper(key => { finalKey = key; finalMap = node is null ? _map : node.Map; if (finalMap.Contains(key)) { node = finalMap[key]; } else { capturedException ??= new ArgumentException("Attempted to remove a non-existing item.", nameof(stepper)); } pathStack.Push((finalKey, finalMap, node)); }); if (capturedException is not null) { exception = capturedException; return(false); } else if (node is null) { exception = new ArgumentException("Stepper was empty.", nameof(stepper)); return(false); } else if (!node.IsLeaf) { exception = new ArgumentException("Attempted to remove a non-existing item.", nameof(stepper)); return(false); } else { bool remove = true; while (pathStack.Count > 0) { var(k, m, n) = pathStack.Pop(); n.Count--; if (remove && n.Count == 0) { m.Remove(k); } else { remove = false; } } _count--; exception = null; return(true); } }
public CannotFindElementByException(By @by, ISearchContext context, Exception?originalException = null) : base($"Cannot find element {by} inside {context.GetElementDescription()}", originalException) { By = @by; Context = context; }
public static extern int GetHRForException(Exception?e);
public AmbiguousImplementationException(string?message, Exception?innerException) : base(message, innerException) { HResult = HResults.COR_E_AMBIGUOUSIMPLEMENTATION; }
private static void RemoveDirectoryRecursive(string fullPath, ref Interop.Kernel32.WIN32_FIND_DATA findData, bool topLevel) { int errorCode; Exception?exception = null; using (SafeFindHandle handle = Interop.Kernel32.FindFirstFile(Path.Join(fullPath, "*"), ref findData)) { if (handle.IsInvalid) { throw Win32Marshal.GetExceptionForLastWin32Error(fullPath); } do { if ((findData.dwFileAttributes & Interop.Kernel32.FileAttributes.FILE_ATTRIBUTE_DIRECTORY) == 0) { // File string fileName = findData.cFileName.GetStringFromFixedBuffer(); if (!Interop.Kernel32.DeleteFile(Path.Combine(fullPath, fileName)) && exception == null) { errorCode = Marshal.GetLastWin32Error(); // We don't care if something else deleted the file first if (errorCode != Interop.Errors.ERROR_FILE_NOT_FOUND) { exception = Win32Marshal.GetExceptionForWin32Error(errorCode, fileName); } } } else { // Directory, skip ".", "..". if (findData.cFileName.FixedBufferEqualsString(".") || findData.cFileName.FixedBufferEqualsString("..")) { continue; } string fileName = findData.cFileName.GetStringFromFixedBuffer(); if (!IsNameSurrogateReparsePoint(ref findData)) { // Not a reparse point, or the reparse point isn't a name surrogate, recurse. try { RemoveDirectoryRecursive( Path.Combine(fullPath, fileName), findData: ref findData, topLevel: false); } catch (Exception e) { if (exception == null) { exception = e; } } } else { // Name surrogate reparse point, don't recurse, simply remove the directory. // If a mount point, we have to delete the mount point first. if (findData.dwReserved0 == Interop.Kernel32.IOReparseOptions.IO_REPARSE_TAG_MOUNT_POINT) { // Mount point. Unmount using full path plus a trailing '\'. // (Note: This doesn't remove the underlying directory) string mountPoint = Path.Join(fullPath, fileName, PathInternal.DirectorySeparatorCharAsString); if (!Interop.Kernel32.DeleteVolumeMountPoint(mountPoint) && exception == null) { errorCode = Marshal.GetLastWin32Error(); if (errorCode != Interop.Errors.ERROR_SUCCESS && errorCode != Interop.Errors.ERROR_PATH_NOT_FOUND) { exception = Win32Marshal.GetExceptionForWin32Error(errorCode, fileName); } } } // Note that RemoveDirectory on a symbolic link will remove the link itself. if (!Interop.Kernel32.RemoveDirectory(Path.Combine(fullPath, fileName)) && exception == null) { errorCode = Marshal.GetLastWin32Error(); if (errorCode != Interop.Errors.ERROR_PATH_NOT_FOUND) { exception = Win32Marshal.GetExceptionForWin32Error(errorCode, fileName); } } } } } while (Interop.Kernel32.FindNextFile(handle, ref findData)); if (exception != null) { throw exception; } errorCode = Marshal.GetLastWin32Error(); if (errorCode != Interop.Errors.ERROR_SUCCESS && errorCode != Interop.Errors.ERROR_NO_MORE_FILES) { throw Win32Marshal.GetExceptionForWin32Error(errorCode, fullPath); } } // As we successfully removed all of the files we shouldn't care about the directory itself // not being empty. As file deletion is just a marker to remove the file when all handles // are closed we could still have undeleted contents. RemoveDirectoryInternal(fullPath, topLevel: topLevel, allowDirectoryNotEmpty: true); }
public LogEvent(Type source, int sourceThread, DateTimeOffset eventOccuredOn, string message, object[]?args, Exception?exception, IAddress?sourceActorAddress) { Source = source; Message = message; Args = args; Exception = exception; SourceThread = sourceThread; EventOccuredOn = eventOccuredOn; SourceActorAddress = sourceActorAddress; }
public Task SendNotificationAsync(FormattableString message, Exception?exception = null) { return(SendNotificationAsync(message.ToString(), exception)); }