Exemplo n.º 1
0
 /// <summary>
 /// Decorates the specified rollbar data.
 /// </summary>
 /// <param name="rollbarData">The rollbar data.</param>
 protected override void Decorate(Data rollbarData)
 {
     if (this._httpContext?.Request != null)
     {
         // here we essentially piggy-back on capabilities of
         // already implemented HttpRequestPackageDecorator
         // instead of this decorator:
         HttpRequestPackageDecorator strategy =
             new HttpRequestPackageDecorator(this._packageToDecorate, new HttpRequestWrapper(this._httpContext.Request));
         strategy.PackageAsRollbarData();
     }
 }
        /// <summary>
        /// Produces the rollbar data.
        /// </summary>
        /// <returns>Rollbar Data DTO or null (if packaging is not applicable in some cases).</returns>
        protected override Data ProduceRollbarData()
        {
            if (this._exceptionContext == null)
            {
                return(null);
            }

            // let's use composition of available strategies:

            IRollbarPackage packagingStrategy = new ExceptionPackage(this._exceptionContext.Exception, this._message);

            var httpRequest = this._exceptionContext?.RequestContext?.HttpContext?.Request;

            if (httpRequest != null)
            {
                packagingStrategy = new HttpRequestPackageDecorator(packagingStrategy, httpRequest);
            }

            Data rollbarData = packagingStrategy.PackageAsRollbarData();

            return(rollbarData);
        }