* Web.csproj:
* LocalizedText.resx: * SimpleFormatter.cs: * TemplateException.cs: * ErrorHtmlFormatter.cs: * LocalizedText.Designer.cs: * WorkFlowManager.cs: * Makefile: refactoring * FrontOfficeApiController.cs: nice html error response in case of error at rendering a tex or pdf document * LocalizedText.fr.resx: Gives as title at rendering a template processing error
This commit is contained in:
parent
e847248366
commit
2f6146c0f7
10 changed files with 163 additions and 13 deletions
|
|
@ -22,6 +22,7 @@ using Yavsc.Formatters;
|
|||
using System.Text;
|
||||
using System.Web.Profile;
|
||||
using System.Collections.Specialized;
|
||||
using Yavsc.Model;
|
||||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
|
|
@ -102,9 +103,28 @@ namespace Yavsc.ApiControllers
|
|||
[AcceptVerbs("GET")]
|
||||
public HttpResponseMessage GetEstimTex(long estimid)
|
||||
{
|
||||
string texest = getEstimTex (estimid);
|
||||
string texest = null;
|
||||
try {
|
||||
texest = getEstimTex (estimid);
|
||||
}
|
||||
catch (TemplateException ex) {
|
||||
return new HttpResponseMessage (HttpStatusCode.OK){ Content =
|
||||
new ObjectContent (typeof(string),
|
||||
ex.Message, new ErrorHtmlFormatter(HttpStatusCode.NotAcceptable,
|
||||
LocalizedText.DocTemplateException
|
||||
))};
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return new HttpResponseMessage (HttpStatusCode.OK){ Content =
|
||||
new ObjectContent (typeof(string),
|
||||
ex.Message, new SimpleFormatter("text/text")) };
|
||||
}
|
||||
if (texest == null)
|
||||
throw new HttpRequestValidationException ("Not an estimation id:"+estimid);
|
||||
return new HttpResponseMessage (HttpStatusCode.OK) { Content =
|
||||
new ObjectContent (typeof(string),
|
||||
"Not an estimation id:" + estimid, new SimpleFormatter ("text/text"))
|
||||
};
|
||||
|
||||
return new HttpResponseMessage () {
|
||||
Content = new ObjectContent (typeof(string),
|
||||
texest,
|
||||
|
|
@ -121,11 +141,11 @@ namespace Yavsc.ApiControllers
|
|||
|
||||
Profile prpro = new Profile(ProfileBase.Create(e.Responsible));
|
||||
if (!prpro.IsBankable)
|
||||
throw new Exception ("NotBankable:"+e.Responsible);
|
||||
throw new TemplateException ("NotBankable:"+e.Responsible);
|
||||
|
||||
Profile prcli = new Profile(ProfileBase.Create(e.Client));
|
||||
if (!prcli.IsBillable)
|
||||
throw new Exception ("NotBillable:"+e.Client);
|
||||
throw new TemplateException ("NotBillable:"+e.Client);
|
||||
tmpe.Session.Add ("from", prpro);
|
||||
tmpe.Session.Add ("to", prcli);
|
||||
tmpe.Init ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue