CKTIS / C#
System.Exception: referencia práctica
System.Exception: referencia práctica: Exception es la base de los fallos administrados y contiene Message, StackTrace y una InnerException opcional.
Versión: .NET API; verified on .NET 10.0.14
Sintaxis
System.Exception /* select a documented member or constructor */Exception es la base de los fallos administrados y contiene Message, StackTrace y una InnerException opcional.
Lanza un tipo más específico y añade contexto sin perder la excepción interna original.
No controles la lógica con Message y usa throw en lugar de throw error para conservar la pila.
StackTrace puede ser null antes del lanzamiento y serializar excepciones no es un protocolo estable entre sistemas.
El programa completo usa realmente System.Exception; su stdout esperado exacto es boom.
Ejemplos
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var error = new Exception("boom");
Console.WriteLine(error.Message);
Resultado
boom
El programa completo usa realmente `System.Exception`; su stdout esperado exacto es `boom`.