Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Witz template cryptic error messages
Witz template cryptic error messages [message #42940] Tue, 15 April 2014 12:29 Go to next message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
Hello !

I'm playing with witz and getting funny cryptic error messages that do not help much to find the problem:
----
Internal server error
Invalid value conversion: int -> N3Upp7WStringE
----
Re: Witz template cryptic error messages [message #42941 is a reply to message #42940] Tue, 15 April 2014 13:03 Go to previous messageGo to next message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
We need somehow a stack trace something like this https://github.com/Nanolat/c-callstack
Re: Witz template cryptic error messages [message #42942 is a reply to message #42940] Tue, 15 April 2014 13:19 Go to previous messageGo to next message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
The problem happen because I have a "$post_identity()" instruction on a form but I'm accessing this page through GET somehow it dies here:
String GetIdentity(const Renderer *r)
{
	// This ugly hack expects that __identity__ is always present in r->var
	Http *http = const_cast<Http *>(dynamic_cast<const Http *>(r));
	if(!http)
		throw Exc("invalid POST identity call");
	String s = http->var[0]; ///<<<<<<<<< it dies here because I'm accessing through get / it's intended to do this way mixed GET/POST
	if(s.GetCount())
		return s;
	s = AsString(Uuid::Create());
	http->SessionSet0("__identity__", s);
	http->var[0] = s;
	return s;
}

Re: Witz template cryptic error messages [message #42943 is a reply to message #42942] Tue, 15 April 2014 13:24 Go to previous messageGo to next message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
Changing the function to this make it works:

String GetIdentity(const Renderer *r)
{
	// This ugly hack expects that __identity__ is always present in r->var
	Http *http = const_cast<Http *>(dynamic_cast<const Http *>(r));
	if(!http)
		throw Exc("invalid POST identity call");
	Value val = http->var[0];
	String s;
	if(IsString(val))
	{
		s = http->var[0];
		if(s.GetCount())
			return s;
	}
	s = AsString(Uuid::Create());
	http->SessionSet0("__identity__", s);
	http->var[0] = s;
	return s;
}

Re: Witz template cryptic error messages [message #42944 is a reply to message #42940] Tue, 15 April 2014 13:40 Go to previous messageGo to next message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
Isn't worth to use something like Lua for witz, it already has all error handling well done and has more capabilities out of box.

I'm not saying to move business logic to templates, but having flexibility to try new things/variations without need to recompile is an interesting feature.

Cheers !
Re: Witz template cryptic error messages [message #42945 is a reply to message #42944] Tue, 15 April 2014 13:58 Go to previous messageGo to next message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
I did a microbenchmark with ESC, lua, luajit, SquiLu:
fact(x)
{
  if (x <= 1) {
    return 1;
  }
  return x * fact (x-1);
}

main() {
    i=0;
    x = 0;
    while (i < 100000) {
		x = fact (12);
		i+= 1;
    }
    Print(to_string(x) + "\n");	
}

$ time ./EscApp
479001600

real 0m4.314s
user 0m4.304s
sys 0m0.000s

$ time squilu fact2.nut
479001600

real 0m0.425s
user 0m0.232s
sys 0m0.008s

$ time luajit fact2.lua
479001600

real 0m0.079s
user 0m0.016s
sys 0m0.000s

$ time lua-5.1.5 fact2.lua
479001600

real 0m0.243s
user 0m0.160s
sys 0m0.000s

[Updated on: Tue, 15 April 2014 13:59]

Report message to a moderator

Re: Witz template cryptic error messages [message #42949 is a reply to message #42941] Wed, 16 April 2014 07:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mingodad wrote on Tue, 15 April 2014 11:03
We need somehow a stack trace something like this https://github.com/Nanolat/c-callstack


Usually, I just run it in debugger.

Stack trace can be activated, the problem is that it requires everything being compiled to .so.
Re: Witz template cryptic error messages [message #42950 is a reply to message #42944] Wed, 16 April 2014 08:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mingodad wrote on Tue, 15 April 2014 11:40
Isn't worth to use something like Lua for witz, it already has all error handling well done and has more capabilities out of box.

I'm not saying to move business logic to templates, but having flexibility to try new things/variations without need to recompile is an interesting feature.

Cheers !


I guess that is quite tough design decision in all template systems.

Before creating witz I was, of course, investigating other templating systems, then defined witz in a way that about permits as much as them.

I would say that if templates are common pactice with PHP framework, then perhaps putting more flexibility into templates is a bad idea (because pure PHP can be considered a templating system with ultimate flexibility Smile.
Re: Witz template cryptic error messages [message #42951 is a reply to message #42942] Wed, 16 April 2014 08:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mingodad wrote on Tue, 15 April 2014 11:19
The problem happen because I have a "$post_identity()" instruction on a form but I'm accessing this page through GET somehow it dies here:


While I agree there might be a problem in Skylark here, I believe it is more complicated that this.

In any case, just looking at the code, post_identity should work just fine with GET (of course, it is sort of weird to use it for GET, but whatever...).

Then I have tried adding $post_identity() to Skylark05 example and it seems to work just fine.

One possibility is that you are using some function that breaks the witz's stack frame.

Perhaps you could post the testcase?

Mirek

[Updated on: Wed, 16 April 2014 08:30]

Report message to a moderator

Re: Witz template cryptic error messages [message #42952 is a reply to message #42945] Wed, 16 April 2014 08:37 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mingodad wrote on Tue, 15 April 2014 11:58
I did a microbenchmark with ESC, lua, luajit, SquiLu:


There is no surprise there, Esc is just a very simple pure scripting language intended (originally) for .usc files, which are widget propery/visuals definitions for Layout Designer.

Note however that Esc is completely unrelated to .witz. Witz is compiled to object representation and runs without interpreting anything. I have benchmarked WITZ and found it about 8 times slower than optimized C++. In real use, witz spends 80-90% of time just concatenating texts, therefore I doubt it would ever be performance bottleneck.

Mirek
Previous Topic: Skylark functions/links
Next Topic: [BUG] GLDraw on multiple window on the same time doesn't work
Goto Forum:
  


Current Time: Thu Mar 28 23:04:48 CET 2024

Total time taken to generate the page: 0.01813 seconds