Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Commit error (raise split exception)
Tue, Oct 8 2013 8:58 AMPermanent Link

lejetou

Here is a simple code :
Database.StartTransaction;
DS.Insert;
DS.Columns['mycol'].AsString:=getColContent;
DS.Save;
Database.Commit

getColContent is a  function.
This function call of an external JS function.

if unfortunatly this external function returns value : undefined

commit raise an exeception : Uncaught TypeError: Cannot call method 'split' of undefined

after a quick look in JS of my app, i've found that "webcore_escapestr" raise this exeception because it is called with undefined parameter (this call is in webdata_tdatavalue.$p.getjson = function() => webcore_escapestr($t.getasstring()))

I'll test the returned value of my function, but as the error message is very confusing, I think it will be better to fix that in the framework.

I think getasstring() should return "" if value is undefined

Best regards
Tue, Oct 8 2013 11:31 AMPermanent Link

Matthew Jones

> I think getasstring() should return "" if value is undefined

It would presumably be even better if it didn't let you set it thus.

/Matthew Jones/
Tue, Oct 8 2013 3:44 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< getColContent is a  function.
This function call of an external JS function. >>

EWB cannot compile/validate external code past the external interface, so it
is the responsibility of the external code to not return invalid data to the
EWB application.  If I were to start introducing type-checking into the
framework, it would defeat the whole purpose of having a compiler at all,
and we'd all be back to using JavaScript just like everyone else where every
single parameter, etc. has to be type-checked for correctness in a defensive
manner.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Oct 8 2013 3:45 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< It would presumably be even better if it didn't let you set it thus. >>

Please see my prior response - doing this would be heading down the road to
making the EWB compiler irrelevant.  This is one of the reasons why EWB is
designed to be strict about requiring an external interface for external JS.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Oct 9 2013 4:03 AMPermanent Link

Matthew Jones

Okay, so it would thus be better, for such things, to have a "SanityCheck()"
routine that did something like

function SanityCheck(StringValue : String);
begin
   Result := StringValue;
   if Result = undefined then // not sure on syntax for this
     raise Error.Create('invalid data');
end;

I forget how to do the check for undefined and exception stuff outside EWB, but
they've been posted here before.

The code would thus become:

DS.Columns['mycol'].AsString:=SanityCheck(getColContent);

/Matthew Jones/
Image