Headless error logging & Method name/Line Number?

I have a database that is hitting some kind of error in Compiled, in Server, and I think in a trigger, while running as service.
The Diagnostic log is reporting:
36998 2020-02-10 10:11:01 [4D Server.4DRT] ERROR - [15] This operation is not compatible with the two arguments., task #-14, task name is Server_Maintenance

Great: I know the task name, and error kind: but I have no idea of the method name/line number.

Is this all the log I’m supposed to get? am I missing something?

So, I’ve tried running as an application. I can re-produce the error: but on the server: a totally blank “Runtime Error” window comes up

How on earth am supposed to debug the error, if I can’t be told a method name & line number?

Hi Tony,

There is supposed to be another entry in the log immediately after that one that includes the information you need. Should be something like this:

Code :
1 2020-02-11 10:16:55 [4D Server.4DRT] ERROR - [-20001] Array range check error., task #-2, task name is Client Manager
2 2020-02-11 10:16:55 [4D Server.HDLS] ERROR - (Error: #-20001 Array range check error.)[{“type”:“databaseMethod”,“name”:“On Server Startup”,“line”:3,“database”:“Sandbox”}]

Strange that you get a blank runtime error without the --headless option. If you use ON ERR CALL, does Get call chain give you anything useful?

Regards,
Adam

Hi Adam,

I use On Err Call everywhere I am aware of: and in my error method: I log the complete error stack and call chain.
I’m not seeing any log of this.
I’ve search the diagnostic logs of my databases many times: and have yet to see a [4D Server.HDLS].
Most of my systems are on 17r6: Although a few are on 18.

The log that you mentioned is fantastic! I wish I was seeing it.

Hi Tony,

I ran my test in v18 as I didn’t think that v17R6 would log runtime errors with the --headless option. From memory logging of alert etc dialogs only came in for v18.

I just tried the same test in v17R6 and found conflicting results. In local 4D it doesn’t stop the runtime error from displaying, while in 4D server it hides the runtime error but doesn’t seem to log anything (unless I’m looking in the wrong spot).

Maybe your error is happening in a 4D component. Whatever it is it must be something that ON ERR CALL can’t trap but 4D also can’t handle properly.

Might have to add some logging in to try and figure out where it is happening (fun ;-))

Tony, you need to use v18 to get the automatic logging.

I tried with different set of possible cases, by example:

ERROR - (Error: #-43 File not found. (File: disk:file))[{“type”:“projectMethod”,“name”:“test”,“line”:1,“database”:“headlesstest”},{“type”:“databaseMethod”,“name”:“On Startup”,“line”:2,“database”:“headlesstest”}]

or calling ALERT (my own error)
WARN - (ALERT: You’re not allowed to do this)[{“type”:“databaseMethod”,“name”:“On Startup”,“line”:1,“database”:“headlesstest”}]

Note: I personally see it as best practice to ALWAYS use ON ERROR CALL as first line in On SERVER Startup and as first line in any started process. In On Server Startup I initialize all my workers by doing an “init” call which runs ON ERR CALL, so every worker is following as well.
This is logging all usual kind of errors, such as the file not found above.
I’m using ASSERT instead of ALERT to notify myself or the admin about errors, as I can fetch ASSERTs using ON ERR CALL as well.

The only reasons for me to use the automatic logging is:

  • developers not using ON ERR CALL or using it wrong
  • developers with forgotten ALERT or REQUEST or similar
  • Runtime Errors (which cannot be fetched by ON ERR CALL - and for those you get reduced information, but at least you get some and they don’t block the server)
  • other Server messages, such as License number expired.

Thanks Thomas,
The database in question is on v18: a nightly build (b247789)

I do start every process of mine with a ON ERR CALL, installing a method that logs any error: including now - the complete call chain (fantastic new feature).

The process in question was a record being updated from 4D Mobile. However, even in my triggers: I have generic code in the trigger that does this:
If (Method called on error="")
Error_Handler (“Init”) `Initialize my ON ERR CALL method
End if

So, I’m quite thorough about this.

I’ll enclose a Diagnostic log: I see plenty of stuff: but nothing with method name/line numbers.
https://forums.4d.com/4DBB_Main/x_User/1166023/files/33799814.7z

And FYI, I found the source problem of my bug:
In a trigger: I’m doing a SQL SELECT Statement: and in that statement: to get the name of my INTO variable, I use RESOLVE POINTER to get a process variable name. The bug is that RESOLVE POINTER got a null string for the variable name. (the name of the variable was “aLong1”).
I saw this happen in one place in 17r6, so I re-coded it. Now, this is a new place in v18. As a policy of SQL Select INTO <>: I use this technique of getting the name via a RESOLVE POINTER: but in two cases that I know about recently: RESOLVE POINTER failed. I’m concerned.

Hi Tony,

Not sur this is any help, but…

You could try to wrap your calls to RESOLVE POINTER and in resolve pointer have an asset (and/or log) where you can write a message about the variable which failed, the calling procedure (with the new call chain command) etc…

Use the global search/replace to RESOLVE POINTER with your wrapper command…

PS : well done for finding the problem :smiley:

Just curious, is it related to variables on the fly https://forums.4d.com/Post/FR/32417162/1/32417163#32417163discussed here>?

Arnaud,
no: it’s not related at all.
I don’t use dynamically created Process vars: after the discussion about it: I took the advice - and didn’t do it.

Bruno,

You could try to wrap your calls to RESOLVE POINTER and in resolve pointer have an asset (and/or log) where you can write a message about the variable which failed, the calling procedure (with the new call chain command) etc…
Yes: I do almost exactly that: and that’s how I found exactly what was failing.
I have a component project method that does the RESOLVE POINTER for me: and if it comes up blank: it logs all the data.

: Tony RINGSMUTH

I have a component project method that does the RESOLVE POINTER for
me: and if it comes up blank: it logs all the data.
I maybe dumb, how can the component resolve a pointer on a host variable?

Arnaud

how can the component resolve a pointer on a host variable?
that’s not a dumb question.

  • The host database passes a pointer to a component method.
  • If the component method receives a valid pointer: it can resolve it.

This has worked for a long time: ever since components existed.

I don’t pretend I fell down from my chair :wink: but really I’m surprised a component can “resolve” a var belonging to the host.