Reply to topic  [ 2 posts ] 
Max length on error argument 
Author Message
Yorick Master

Joined: Wed Jun 01, 2005 11:34 am
Posts: 112
Post Max length on error argument
The function "error" accepts a string as an argument, which will be printed as part of the error message. However, only the first 140 characters of this string will be used. The "exit" function, on the other hand, will apparently accept and print input of much greater length (perhaps effectively unbounded).

I managed to find where in the code this restriction is occurring. It is in file task.c at line 1686, in function YError. The relevant lines:
Code:
  if (!pcUp || recursing)
    strncat(yErrorMsg, msg, 140);

I suspect the limitation is intentional, since it's hard-coded. If you decide not to change it, please consider updating the documentation to mention this behavior.


Tue Dec 07, 2010 9:44 am
Profile
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post 
I could make it handle more characters, but I can't make it unlimited, because one of the very likely causes of an error is failure of the memory manager. If you want long error messages, you can (I'm sure you realized) create a custom error function that prints a message of arbitrary length with the usual yorick print function before calling error. You can use the relatively new errs2caller function to make your private error function behave like the public error, so you wind up in its caller in dbug mode.


Wed Dec 08, 2010 7:30 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.