mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 21
V
Vile Offline OP
Ameglian cow
OP Offline
Ameglian cow
V
Joined: Dec 2002
Posts: 21
How about something like $scriptline but for use with the :error goto. Something like what $scriptline does, the problem is $scriptline is only for the current line within the current alias/event.

How about something that gives the event or alias and line number of whatever called the specific identifier/alias.

Example:

Code:
on *:JOIN:#:{
; stuff here
 did -a joindialog 1 $nick
}
alias did {
!did $1-
:error
if ($2 == joindialog) echo -a error $error -- event: $callevent line: $callline file: $callfile
}

would echo something like "error /did: insufficient parameters (line 7, stuff.als) -- event: onJoin line: 253 file: otherstuff.mrc "

the 'event' could be the name of the remote event, or if it's an alias that calls the other alias. so $callevent could be "$identifier", "/alias", "onjoin", "raw352"

as the error reporting works now it will just give you the line number and file of whatever failed, it doesn't take inheritance into account.

I think it would be debugging problems a lot easier.

Yes I realize there are ways of tracking down bugs manually, but this would allow you to trace bugs more easily. Plus if other people use your script and the error they're getting is an alias called by dozens of places it's harder to track down what called it in the first place, if it called it with improper parameters.

I didn't write this out well. Need sleep.
TL;DR: ways to reference what line and script actually trigger an error within an alias or identifier.



Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
This was suggested before.

It doesn't really solve the problem though, it would be a really half-hearted solution to error messages. Specifically because not every command raises an :error, and users can't raise their own custom errors. So while it works for extremely basic debugging (mostly just syntax errors), it doesn't really scale up to anything useful. As a sidenote, if you get rid of the :error, you technically will already get that /did insufficient parameters, so again, the benefit isn't really in terms of debugging, it's in customizing error messages, which, again, is already severely limited.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Nov 2011
Posts: 10
D
Pikka bird
Offline
Pikka bird
D
Joined: Nov 2011
Posts: 10
I'd like to extend that idea for even more simple debugging.

Code:
; $callstack(N).prop   - returns information about the call stack of the script.
;
; $callstack(0)        - returns the size of the call stack
; $callstack(1).file   - returns the file name of the current script (like $script if N=1)
; $callstack(1).line   - returns the line number of the current script
;                         (NOT like $scriptline if N=1 - should be the line where the error occured)
; $callstack(2).type   - returns the type of the calling script (event, alias, identifier)
; $callstack(2).name   - returns the name of the calling script 
;                         ("join" for on JOIN events, "bleh" for an alias or identifier called "bleh", ...)
; $callstack(2).params - returns the parameters given to the alias (like $1- if N=1)
;
; $cerror - returns the error without file/line info (yes, you can script that by yourself)

on *:JOIN:#:{
  addnick $nick
}

alias addnick {
  ; Note that i "forgot" to give the control number
  did -a joindialog $1
}

alias did {
  !did $1-
  :error
  if ($2 == joindialog) {
    echo -a error: $cerror
    var %i 1
    while ($callstack(%i).type) {
      echo -a $iif(%i == 1,in:,called by:) $callstack(%i).type $callstack(%i).name $&
        file: $callstack(%i).file line $callstack(%i).line params: $callstack(%i).params
      inc %i
    }
  }
}

; Example output:
;
; error: /did: 'joindialog' invalid id '0'
; in: alias did file: something.mrc line 24 params: -a joindialog somenick
; called by: alias addnick file: something.mrc line 20 params: somenick
; called by: event join file: something.mrc line 15 params:


An alternative for the last line could be that there's a different $callstack().type for normal events ("on"), "ctcp" and "raw". In my opinion, "called by: on join" looks better than "event join".

Another idea would be not having to script this by yourself, but a built-in command called /callstack or something that puts this information into a file, a dialog box or a custom @window.

Feel free to comment or extend this idea.

Last edited by D4ni; 24/04/12 02:36 PM.

Link Copied to Clipboard