"Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum" <10353@lyskom.lysator.liu.se> wrote:
You need to put your code inside a function. Try calling it "main".
Well I was hoping that would be assumed.
But maybe me posting the whole bit of code will help...
void handle_error(array|object trace, void|object o)
{
if(mixed x=catch {
object ferr = Stdio.File("C:/EMAGE/sys/data/log/run.c", "wca+");
string sWrite = describe_backtrace(trace);
int nLine;
string sFunc;
string sFile;
string sParams;
string sOut = "";
if(o)
{
sOut += "Error occured in: " + object_name(o) + "\n";
}
foreach(sWrite/"\n", string s)
{
if(sscanf(s, "%s:%d:%*s->%s(%s", sFile, nLine, sFunc, sParams) == 5)
{
string sLine = (string)nLine;
string sTemp = " ";
sLine = sTemp[0 .. sizeof(sTemp) - sizeof(sLine)] + sLine + " ";
sTemp =
" ";
sFunc = sFunc + sTemp[0 .. sizeof(sTemp) - sizeof(sFunc)];
sOut += sLine + sFunc + sFile + " (" + sParams + ")\n";
}
else
{
if(s != "")
{
sOut += s + "\t" + ctime(time());
}
}
}
sOut += "\n";
ferr->Write(sOut);
}) {
// One reason for this might be too little stack space, which
// easily can occur for "out of stack" errors. It should help to
// tune up the STACK_MARGIN values in interpret.c then.
werror("Error in handle_error in master object:\n");
if(catch {
catch {
if (catch {
string msg = [string]x[0];
werror("%s", msg);
array bt = [array]x[1];
werror("%O\n", bt);
}) {
werror("%O\n", x);
}
};
werror("Original error:\n"
"%O\n", trace);
}) {
werror("sprintf() failed to write error.\n");
}
}
}
now this is inside a modified master.pike. The code has worked on previous versions of pike. So not sure why it does not work now.