Embed inner exception (ARCH403)
Esta página aún no está disponible en tu idioma.
Key dotnet.exception.embed-inner-exception · Severity warning · Category exception
When throwing a new exception inside a catch block, pass the caught exception as the innerException. Otherwise the original stack trace and error context are lost.
Incorrect
Section titled “Incorrect”try{ _repository.Save(order);}catch (DbException ex){ throw new OrderSaveException("Could not save order");}Correct
Section titled “Correct”try{ _repository.Save(order);}catch (DbException ex){ throw new OrderSaveException("Could not save order", ex);}Pass the caught exception as the innerException to the new exception’s constructor. If needed, suppress the rule per project/workspace via except/ignore.