Skip to content

Commit 8b97e27

Browse files
author
Chris Young
committed
Reversed 4.4.0
1 parent 77bf3c8 commit 8b97e27

File tree

5 files changed

+39
-31
lines changed

5 files changed

+39
-31
lines changed

src/ArchitectNow.Models/Exceptions/ApiException.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ protected ApiException(HttpStatusCode statusCode, string message, Exception inne
2424
}
2525

2626
public abstract string GetContent();
27+
28+
public virtual object GetRawContent()
29+
{
30+
return InternalContent;
31+
}
2732
}
2833

2934
public class ApiException<TContent>: ApiException, IApiException<TContent>
@@ -56,5 +61,5 @@ public override string GetContent()
5661
}
5762
return null;
5863
}
59-
}
64+
}
6065
}

src/ArchitectNow.Mongo/MongoModule.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ public class MongoModule: Module
1313
{
1414
protected override void Load(ContainerBuilder builder)
1515
{
16-
builder.RegisterAssemblyTypes(ThisAssembly).AsImplementedInterfaces().PreserveExistingDefaults();
16+
builder.RegisterAssemblyTypes(ThisAssembly).AsImplementedInterfaces();
1717

1818
builder.RegisterType<MongoDataContextService>().As<IDataContextService<MongoDataContext>>()
19-
.InstancePerLifetimeScope().PreserveExistingDefaults();
19+
.InstancePerLifetimeScope();
2020

21-
builder.Register(context => context.Resolve<IConfigurationRoot>().CreateOptions<MongoOptions>("mongo")).As<IOptions<MongoOptions>>().SingleInstance().PreserveExistingDefaults();
21+
builder.Register(context => context.Resolve<IConfigurationRoot>().CreateOptions<MongoOptions>("mongo")).As<IOptions<MongoOptions>>().SingleInstance();
2222
}
2323
}
2424
}

src/ArchitectNow.Services/ServicesModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public class ServicesModule : Module
88
{
99
protected override void Load(ContainerBuilder builder)
1010
{
11-
builder.RegisterAssemblyTypes(ThisAssembly).AsImplementedInterfaces().PreserveExistingDefaults();
12-
builder.RegisterType<BaseCacheService<CachingOptions>>().As<ICacheService>().SingleInstance().PreserveExistingDefaults();
11+
builder.RegisterAssemblyTypes(ThisAssembly).AsImplementedInterfaces();
12+
builder.RegisterType<BaseCacheService<CachingOptions>>().As<ICacheService>().SingleInstance();
1313
}
1414
}
1515
}

src/ArchitectNow.Web/Services/ExceptionResultBuilder.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,31 @@ public IActionResult Build(Exception exception)
5454
message = apiException.GetBaseException().Message;
5555
}
5656
}
57-
58-
var apiError = new ApiError
59-
{
60-
Error = content ?? message
61-
};
6257

63-
if (!string.IsNullOrEmpty(stackTrace))
64-
{
65-
apiError.StackTrace = stackTrace;
66-
}
58+
return CreateActionResult(content, message, stackTrace, statusCode, exception);
59+
}
6760

68-
var objectResult = new ObjectResult(apiError)
69-
{
70-
StatusCode = statusCode
71-
};
72-
var eventId = new EventId(statusCode);
61+
protected virtual IActionResult CreateActionResult(string content, string message, string stackTrace, int statusCode, Exception exception)
62+
{
63+
var apiError = new ApiError
64+
{
65+
Error = content ?? message
66+
};
7367

74-
_logger.LogError(eventId, exception, message);
68+
if (!string.IsNullOrEmpty(stackTrace))
69+
{
70+
apiError.StackTrace = stackTrace;
71+
}
7572

76-
return objectResult;
77-
}
73+
var objectResult = new ObjectResult(apiError)
74+
{
75+
StatusCode = statusCode
76+
};
77+
var eventId = new EventId(statusCode);
78+
79+
_logger.LogError(eventId, exception, message);
80+
81+
return objectResult;
82+
}
7883
}
7984
}

src/ArchitectNow.Web/WebModule.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ public class WebModule : Module
1717
protected override void Load(ContainerBuilder builder)
1818
{
1919
var assembly = ThisAssembly;
20-
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces().PreserveExistingDefaults();
20+
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
2121

2222
builder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance();
23-
builder.RegisterType<RaygunJobFilter>().AsSelf().InstancePerLifetimeScope().PreserveExistingDefaults();
23+
builder.RegisterType<RaygunJobFilter>().AsSelf().InstancePerLifetimeScope();
2424

25-
builder.RegisterType<GlobalExceptionFilter>().AsSelf().InstancePerLifetimeScope()
26-
.PreserveExistingDefaults();
25+
builder.RegisterType<GlobalExceptionFilter>().AsSelf().InstancePerLifetimeScope();
2726

2827
builder.Register(context =>
2928
{
@@ -36,8 +35,7 @@ protected override void Load(ContainerBuilder builder)
3635
return signingKey;
3736
})
3837
.AsSelf()
39-
.SingleInstance()
40-
.PreserveExistingDefaults();
38+
.SingleInstance();
4139

4240
builder.Register(context =>
4341
{
@@ -49,15 +47,15 @@ protected override void Load(ContainerBuilder builder)
4947
issuerOptions.SigningCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256Signature);
5048

5149
return new OptionsWrapper<JwtIssuerOptions>(issuerOptions);
52-
}).As<IOptions<JwtIssuerOptions>>().InstancePerLifetimeScope().PreserveExistingDefaults();
50+
}).As<IOptions<JwtIssuerOptions>>().InstancePerLifetimeScope();
5351

5452
builder.Register(context =>
5553
{
5654
var configurationRoot = context.Resolve<IConfigurationRoot>();
5755
var key = configurationRoot["RaygunSettings:ApiKey"];
5856
var raygunClient = new RaygunClient(key);
5957
return raygunClient;
60-
}).AsSelf().PreserveExistingDefaults();
58+
}).AsSelf();
6159
}
6260
}
6361
}

0 commit comments

Comments
 (0)