Skip to content

Commit

Permalink
Added custom exception type to be used when app startup fails
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenba committed Aug 6, 2015
1 parent 3eb5287 commit e0e27c0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/NuGetGallery/App_Start/AppActivator.cs
Expand Up @@ -62,7 +62,7 @@ public static void PostStart()
{
if (!OwinStartup.HasRun)
{
throw new NullReferenceException("The OwinStartup module did not run. Make sure the application runs in an OWIN pipeline and Microsoft.Owin.Host.SystemWeb.dll is in the bin directory.");
throw new AppActivatorException("The OwinStartup module did not run. Make sure the application runs in an OWIN pipeline and Microsoft.Owin.Host.SystemWeb.dll is in the bin directory.");
}

// Get configuration from the kernel
Expand Down
1 change: 1 addition & 0 deletions src/NuGetGallery/NuGetGallery.csproj
Expand Up @@ -1057,6 +1057,7 @@
<Content Include="Content\Logos\dnf.png" />
<Content Include="Scripts\jquery-1.11.0.js" />
<Content Include="Scripts\jquery-1.11.0.min.js" />
<Compile Include="Services\AppActivatorException.cs" />
<Compile Include="Services\ConfirmOwnershipResult.cs" />
<Compile Include="Services\CuratedFeedService.cs" />
<Compile Include="Services\ICuratedFeedService.cs" />
Expand Down
24 changes: 24 additions & 0 deletions src/NuGetGallery/Services/AppActivatorException.cs
@@ -0,0 +1,24 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Runtime.Serialization;

namespace NuGetGallery
{
/// <summary>
/// Exception thrown when application startup fails.
/// </summary>
[Serializable]
public class AppActivatorException : Exception
{
public AppActivatorException() { }
public AppActivatorException(string message) : base(message) { }
public AppActivatorException(string message, Exception inner) : base(message, inner) { }
protected AppActivatorException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{ }
}
}
@@ -1,9 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;

namespace NuGetGallery
{
Expand All @@ -17,8 +16,8 @@ public class StatisticsReportNotFoundException : Exception
public StatisticsReportNotFoundException(string message) : base(message) { }
public StatisticsReportNotFoundException(string message, Exception inner) : base(message, inner) { }
protected StatisticsReportNotFoundException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context)
SerializationInfo info,
StreamingContext context)
: base(info, context) { }
}
}

0 comments on commit e0e27c0

Please sign in to comment.