client - Breeze Server-Side errors and Sql triggers -


how sql server database trowed errors details @ client side (like sql raiserror level) using breeze manager perhaps in savechanges fail function. example :

// server-side (sql-server : trigger - after insert)      raiserror ('espace utilise par place, cannot delete.', 16, 1)     rollback tran     return  // client-side (breeze : savechanges - savefailed)             var savechanges = function () {           .....           function savefailed(error) {                 var msg = 'save failed: ' + geterrormessages(error);                 logerror(msg, error);                 error.message = msg;                 throw error;           }      }; 

update 1 : ok, after updated breeze version 1.4.1 i've got error details @ client :

a) application stop @ server-side (breeze controller api) invalidoperationexception @ code bellow point without debug breakpoint assigned.

 [httppost]  public saveresult savechanges(jobject savebundle)  {    return _contextprovider.savechanges(savebundle);  } 

b) if force continue, errors @ client side @ breeze savechanges savefailed level. how manage error bypass breeze server-side api controller error handler continue have related infos @ client?

in waiting adequate answer i'm trying reported these business rules @ beforesaveentities scope. painful prohibit use of triggers rules in lieu of beforesaveentities : don't have same functions.

did consider re-implementing savechanges web api method try/catch?

you should able intercept exception, analyze it, , change whatever response think suitable client.

update aug 21, 2013

i want clear question , answer. if nothing , there uncaught exception in web api method, breeze.net on server should forward error , breezejs forward savechanges fail handler. conforms experience, correct?

i assumed wanted intercept exception on server , perhaps re-shape exception client or compose own (failing) response client. purpose recommended try/catch.

what kind of trouble having "trying decorate server side savechanges try/catch"? thought should catch exceptions thrown sql server ... perhaps not. execution might take place outside of web api method, within scope of [breezecontrollerattribute] (which delegates [breezequeryableattribute] wraps web api [queryableattribute]).

is problem now?

upon further reflection, better place try/catch may in override of savechangescore method in custom (derived) implementation of efcontextprovider:

 public class yourcustomprovider : efcontextprovider<yourdbcontext> {     protected override void savechangescore(saveworkstate saveworkstate)     {         try         {             base.savechangescore(saveworkstate);         }         catch (system.exception ex)         {             // whatever         }            } } 

if doesn't catch it, breakdown harder reach , have made argument breeze.net provide exception handling hook in scope of [breezequeryableattribute].

as workaround might have re-implement [breezecontrollerattribute] (it open source) provide hook yourself. if ... , works ... please send (clone/fork/pull request) other may benefit. we'll investigate independently when have moment.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -