Skip to content

Commit

Permalink
More useful exception (than an NRE) when using HttpContextLifecycle o…
Browse files Browse the repository at this point in the history
…utside of a web request.
  • Loading branch information
ghay committed Feb 15, 2011
1 parent 3378ffa commit 5f811f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/StructureMap/Pipeline/HttpContextLifecycle.cs
Expand Up @@ -49,6 +49,9 @@ public static void DisposeAndClearAll()

protected virtual IDictionary findHttpDictionary()
{
if (!HasContext())
throw new StructureMapException(309);

return HttpContext.Current.Items;
}
}
Expand Down
3 changes: 3 additions & 0 deletions Source/StructureMap/StructureMapException.resx
Expand Up @@ -280,4 +280,7 @@
<data name="25" xml:space="preserve">
<value>Only a concrete type may be used here</value>
</data>
<data name="309" xml:space="preserve">
<value>You cannot use the HttpContextLifecycle outside of a web request. Try the HybridLifecycle instead.</value>
</data>
</root>

0 comments on commit 5f811f6

Please sign in to comment.