Skip to content

Commit

Permalink
Merge pull request #596 from WideSpectrumComputing/master
Browse files Browse the repository at this point in the history
- feat: resolve #532
  • Loading branch information
akornich authored Sep 17, 2021
2 parents 917873c + d7969e4 commit 8117a15
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Each plug-in maintains its own versioning schema and is distributed as its own N
## More Information about the SDK

More details about Rollbar.NET usage and API reference are available at [Rollbar.NET SDK Documentation](https://docs.rollbar.com/docs/dotnet).
v5 specific documentation is available [here]((https://docs.rollbar.com/docs/net-v5).
v5 specific documentation is available [here](https://docs.rollbar.com/docs/net-v5).

## Help / Support

Expand Down
8 changes: 8 additions & 0 deletions Rollbar.App.Config/RollbarConfigSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public bool? Transmit
public bool? RethrowExceptionsAfterReporting
=> this["rethrowExceptionsAfterReporting"] as bool?;

/// <summary>
/// Gets or sets a value indicating whether to wrap reported exception with a Rollbar exception.
/// </summary>
/// <value><c>true</c> if to wrap reported exception with a Rollbar exception; otherwise, <c>false</c>.</value>
[ConfigurationProperty("wrapReportedExceptionWithRollbarException", IsRequired = false, DefaultValue = true)]
public bool? WrapReportedExceptionWithRollbarException
=> this["wrapReportedExceptionWithRollbarException"] as bool?;

/// <summary>
/// Gets a value indicating whether to enable local payload store.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion Rollbar.NetCore.AspNet/RollbarMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,14 @@ public async Task Invoke(HttpContext? context)
RollbarLocator.RollbarInstance.Critical(rollbarPackage);
}

throw new RollbarMiddlewareException(ex);
if(RollbarLocator.RollbarInstance.Config.RollbarDeveloperOptions.WrapReportedExceptionWithRollbarException)
{
throw new RollbarMiddlewareException(ex);
}
else
{
throw;
}
}
finally
{
Expand Down
54 changes: 41 additions & 13 deletions Rollbar/Config/RollbarDeveloperOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,25 @@ public class RollbarDeveloperOptions
/// </summary>
private readonly static TimeSpan defaultPayloadPostTimeout = TimeSpan.FromSeconds(30);
/// <summary>
/// The default log level
/// The default value for log level
/// </summary>
private const ErrorLevel defaultLogLevel = ErrorLevel.Debug;
/// <summary>
/// The default enabled
/// The default value for enabled
/// </summary>
private const bool defaultEnabled = true;
/// <summary>
/// The default transmit
/// The default value for transmit
/// </summary>
private const bool defaultTransmit = true;
/// <summary>
/// The default rethrow exceptions after reporting
/// The default value for rethrow exceptions after reporting
/// </summary>
private const bool defaultRethrowExceptionsAfterReporting = false;
/// <summary>
/// The default value for wrap reported exception with rollbar exception
/// </summary>
private const bool defaultWrapReportedExceptionWithRollbarException = true;

/// <summary>
/// Initializes a new instance of the <see cref="RollbarDeveloperOptions"/> class.
Expand All @@ -43,12 +47,22 @@ public class RollbarDeveloperOptions
/// <param name="enabled">if set to <c>true</c> [enabled].</param>
/// <param name="transmit">if set to <c>true</c> [transmit].</param>
/// <param name="rethrowExceptionsAfterReporting">if set to <c>true</c> [rethrow exceptions after reporting].</param>
/// <param name="wrapReportedExceptionWithRollbarException">if set to <c>true</c> [wrap reported exception with rollbar exception].</param>
public RollbarDeveloperOptions(
ErrorLevel logLevel = RollbarDeveloperOptions.defaultLogLevel,
bool enabled = RollbarDeveloperOptions.defaultEnabled,
bool transmit = RollbarDeveloperOptions.defaultTransmit,
bool rethrowExceptionsAfterReporting = RollbarDeveloperOptions.defaultRethrowExceptionsAfterReporting)
: this(logLevel, enabled, transmit, rethrowExceptionsAfterReporting, RollbarDeveloperOptions.defaultPayloadPostTimeout)
bool rethrowExceptionsAfterReporting = RollbarDeveloperOptions.defaultRethrowExceptionsAfterReporting,
bool wrapReportedExceptionWithRollbarException = RollbarDeveloperOptions.defaultWrapReportedExceptionWithRollbarException
)
: this(
logLevel,
enabled,
transmit,
rethrowExceptionsAfterReporting,
wrapReportedExceptionWithRollbarException,
RollbarDeveloperOptions.defaultPayloadPostTimeout
)
{
}

Expand All @@ -59,19 +73,23 @@ public RollbarDeveloperOptions(
/// <param name="enabled">if set to <c>true</c> [enabled].</param>
/// <param name="transmit">if set to <c>true</c> [transmit].</param>
/// <param name="rethrowExceptionsAfterReporting">if set to <c>true</c> [rethrow exceptions after reporting].</param>
/// <param name="wrapReportedExceptionWithRollbarException">if set to <c>true</c> wrap reported exception with a Rollbar exception.</param>
/// <param name="payloadPostTimeout">The payload post timeout.</param>
public RollbarDeveloperOptions(
ErrorLevel logLevel,
bool enabled,
bool transmit,
bool rethrowExceptionsAfterReporting,
TimeSpan payloadPostTimeout)
bool rethrowExceptionsAfterReporting,
bool wrapReportedExceptionWithRollbarException,
TimeSpan payloadPostTimeout
)
{
LogLevel = logLevel;
Enabled = enabled;
Transmit = transmit;
RethrowExceptionsAfterReporting = rethrowExceptionsAfterReporting;
PayloadPostTimeout = payloadPostTimeout;
this.LogLevel = logLevel;
this.Enabled = enabled;
this.Transmit = transmit;
this.RethrowExceptionsAfterReporting = rethrowExceptionsAfterReporting;
this.WrapReportedExceptionWithRollbarException = wrapReportedExceptionWithRollbarException;
this.PayloadPostTimeout = payloadPostTimeout;
}

/// <summary>
Expand Down Expand Up @@ -118,6 +136,16 @@ public bool RethrowExceptionsAfterReporting
set;
}

/// <summary>
/// Gets or sets a value indicating whether to wrap reported exception with a Rollbar exception.
/// </summary>
/// <value><c>true</c> if to wrap reported exception with a Rollbar exception; otherwise, <c>false</c>.</value>
public bool WrapReportedExceptionWithRollbarException
{
get;
set;
}

/// <summary>
/// Gets the payload POST timeout.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Rollbar/Config/RollbarLoggerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ private void SetDefaults()
this._rollbarDeveloperOptions.Enabled = true;
this._rollbarDeveloperOptions.Transmit = true;
this._rollbarDeveloperOptions.RethrowExceptionsAfterReporting = false;
this._rollbarDeveloperOptions.WrapReportedExceptionWithRollbarException = true;

this._httpProxyOptions.ProxyAddress = null;
this._httpProxyOptions.ProxyUsername = null;
Expand Down
9 changes: 9 additions & 0 deletions Rollbar/IRollbarDeveloperOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ bool RethrowExceptionsAfterReporting
get; set;
}

/// <summary>
/// Gets or sets a value indicating whether to wrap reported exception with a Rollbar exception.
/// </summary>
/// <value><c>true</c> if to wrap reported exception with a Rollbar exception; otherwise, <c>false</c>.</value>
bool WrapReportedExceptionWithRollbarException
{
get; set;
}

/// <summary>
/// Gets the payload POST timeout.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion SdkCommon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<SdkVersionSuffix>beta</SdkVersionSuffix> <!-- Optional. Examples: alpha, beta, preview, RC etc. -->
<SdkLtsRelease>false</SdkLtsRelease> <!-- Optional. Examples: false (default) or true. -->
<SdkReleaseNotes> <!-- Required -->
- refactor: resolve #587 - Update Rollbar.NET's dependency on Newtonsoft.Json package to current version 13.0
- feat: resolve #532 - Make RollbarMiddlewareException wrapper optional based on config settings
- feat: resolve #408 - Invalid configuration file prototype error
- refactor: resolve #587 - Update Rollbar.NET's dependency on Newtonsoft.Json package to current version 13.0
- docs: updated README.md
</SdkReleaseNotes>

Expand Down

0 comments on commit 8117a15

Please sign in to comment.