Always include an innerException when re-throwing

Hiding the previous thrown exception is a bad practice.
This commit is contained in:
Andres G. Aragoneses 2016-10-24 14:58:04 +08:00
parent c644bac4e4
commit 3639ae3e88
2 changed files with 4 additions and 3 deletions

View file

@ -49,9 +49,10 @@ namespace TLSharp.Tests
{ {
return new TelegramClient(ApiId, ApiHash); return new TelegramClient(ApiId, ApiHash);
} }
catch (MissingApiConfigurationException) catch (MissingApiConfigurationException ex)
{ {
throw new Exception($"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})"); throw new Exception($"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})",
ex);
} }
} }

View file

@ -21,7 +21,7 @@ namespace TeleSharp.TL
} }
catch(Exception ex) catch(Exception ex)
{ {
throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !"); throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !", ex);
} }
if (t.IsSubclassOf(typeof(TLMethod))) if (t.IsSubclassOf(typeof(TLMethod)))
{ {