mIRC Home    About    Download    Register    News    Help

Print Thread
#121617 30/05/05 08:57 AM
Joined: Dec 2002
Posts: 208
H
Hrung Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
I think it would be nice if there were an /error command so that we can create our own error messages in aliases, which can be handled in the calling script using normal error handling (:error, $error, and /reseterror), or spit out an error message to the active window, like any command/$identifier with invalid parameters. Also, /error should halt/return the alias it is used in. For example:

Code:
alias test1 {
  test2 1
  halt
  :error
  echo -a $error
  reseterror
}
alias test2 {
  if ($1 != 2) error parameter must be 2
  echo -a we never get here, because /error halts.
}


The "* aliasname:" and "(line N, script.mrc)" of the line where the erring alias is called, where applicable, would be added by mIRC, so that the /error command in the previous example will create a $error like:

* /test2: parameter must be 2 (line 2, script.mrc)

If no error handling is used by the scripts, or the command is used at the command line, it should be echo'd out as a normal error message for a built-in command would be.

I'm hoping against all hope that all of the above semi-sleep-deprived ramblings made sense..


edit: Also, mIRC would need to prefix the alias name in $error with / or $, depending on how it is used in the script that calls said alias.

Last edited by Hrung; 30/05/05 08:59 AM.

If I knew now what I will know then... maybe things will have been different...
#121618 30/05/05 05:22 PM
Joined: Jul 2003
Posts: 77
B
Babel fish
Offline
Babel fish
B
Joined: Jul 2003
Posts: 77
well if your looking for a crappy way to do it for now then you can always do something like this

Code:
  
myerrorscript {
  if (!$1) $error(myerrorscript,$script,$scriptline,Invalid Parameters)
  echo -a Complete
}
error { 
  echo -a * / $+ $$1 $+ : $$4 (line $$3 $+ , $remove($$2,$mircdir) $+ )
  halt
}

* /myerrorscript: Invalid Parameters (line 61, aliases.ini)


hmmm signed by me
#121619 31/05/05 04:40 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Nice ideas except for this one:

Quote:
echo -a we never get here, because /error halts.


Often I like to give 'warnings' (the script continues but you get a warning), I don't think /error should halt.

I'd also like to see some kind of error handling on a global scale:

Code:
on *:mircerror:*:{
  ; $error - the error.
  ; $etype - what caused the error? - alias/commandline/dialog/event/menu
  ; $script - script the error called from/found in.
  ; $scriptline - script line number.
}


New username: hixxy
#121620 31/05/05 06:33 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
The point of having the error command is to emulate mIRC's built-in errors. That means they should halt. When an actual error occurs it's because something's wrong, so there's no way for a script to continue past that point.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#121621 31/05/05 11:39 PM
Joined: Dec 2002
Posts: 208
H
Hrung Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
Quote:
The point of having the error command is to emulate mIRC's built-in errors. That means they should halt. When an actual error occurs it's because something's wrong, so there's no way for a script to continue past that point.


Yes, that is exactly what I had in mind.


If I knew now what I will know then... maybe things will have been different...
#121622 01/06/05 11:44 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Maybe provide a -c(ontinue) or -w(arning) switch to /error so it doesn't halt, keeping the default of halting the script.

Or make another command /warning to do just that: give warnings smile

#121623 02/06/05 08:58 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
I agree, but I don't see the point in limiting us to only throwing errors if we halt the script when all that needs to be added is a single extra line/command: 'halt'


New username: hixxy
#121624 03/06/05 08:37 PM
Joined: Dec 2002
Posts: 208
H
Hrung Offline OP
Fjord artisan
OP Offline
Fjord artisan
H
Joined: Dec 2002
Posts: 208
Quote:
all that needs to be added is a single extra line/command: 'halt'


The /halt command isn't exactly the same as what an error does. /halt automatically stops all event/alias processing, while an error will only halt to the first place it can find an :error. The proposed /error does guarantee the immediate cessation of the alias in which it is used, but that is all. That is no different from when a built-in command gives an error. For example, $gettok(1) gives an error, and does not return a result. It halts right there. The idea is if you were to write your own alias/identifier, you can make it act more like mIRC's built-in ones and give error messages. Standard error handling can allow work to continue, maybe giving a warning message as well? I've never seen an mIRC command give a warning, but continue on regardless.

But I don't understand how a "warning" is any different from, or more useful than, an /echo. I must be blind to the use of giving warning messages, other than while debugging. To me, it's just a way of saying "You gave me the wrong input, but I'm going to pretend it's okay and give you a result anyway, whether it's useful or not." Can you elucidate?

Last edited by Hrung; 03/06/05 08:44 PM.
#121625 30/06/05 01:20 AM
Joined: Jun 2005
Posts: 4
S
Self-satisified door
Offline
Self-satisified door
S
Joined: Jun 2005
Posts: 4
I'm brazilian and no speak english right...
Command is very smile smile smile smile smile smile smile smile smile smile


Link Copied to Clipboard