Class ExceptionExtensions
- Namespace
- NuvTools.Common.Exceptions
- Assembly
- NuvTools.Common.dll
Provides extension methods for Exception objects.
public static class ExceptionExtensions
- Inheritance
-
ExceptionExtensions
- Inherited Members
Methods
AggregateExceptionMessages(Exception, short)
Aggregates exception messages including inner exceptions up to a specified level.
public static string AggregateExceptionMessages(this Exception exception, short level = 0)
Parameters
exceptionExceptionThe exception to process.
levelshortThe number of inner exception levels to include. Use 0 to include only the top-level exception message.
Returns
- string
A formatted string containing the exception message(s) with level indicators.
Remarks
When level is 0, only the top-level exception message is returned. When level is greater than 0, inner exceptions are included up to the specified depth, with each level clearly marked (e.g., "Level 0: ...", "Level 1: ...").
Exceptions
- ArgumentNullException
Thrown when
exceptionis null.