Hi David
We have a similar feature request registered http://compositec1.codeplex.com/workitem/1341
As always there're a few ways you can work around it:
1) Create a "wrapper" function that would be calling underlying SQL function, and in the case it fails, it may do a f.e. a redirect to "Website temporarily unavailable" page.
To do that you would have to write an implementation of Composite.Functions.Plugins.FunctionProvider.IFunctionProvider
and add it to the appropriate section in web.config.
It will return an IFunction instance that will do the necessary work. It would have a method like:
public override object Execute(ParameterList parameters, FunctionContextContainer context)
{
try {
return parameters.GetParameter<XElement>("InnerFunction");
}
catch (SqlException){
HttpContext.Current.Response.Redirect("/......", true);
}
}
That approach could be a bit tricky if you aren't writendly with the function api yet, also you would may have to change many code lines to have this approach
2) You can create a response filter, that would check if there's <span class="c1error">[ Error ]</span> in the response, and if there is, it would do a redirect
This one is much easier, check out implementation of class Composite.Core.WebClient.HttpModules.AdministrativeResponseFilterHttpModule
that is a working example of how to add a filter, you just have to write your own stream, something like this:
internal class ErrorRedirectStream : Utf8StringTransformationStream
{
public ErrorRedirectStream(Stream innerStream) : base(innerStream) { }
public override string Process(string str)
{
if (str.Contains("class=\"c1error\""))
{
HttpContext.Current.Response.Redirect("/MyNoSqlConnecitonPage");
}
return str;
}
}
|