if i userstand it right the :error will only be used if a error occur? $error return nothing.
Not exactly, "
:error" is just a goto label (mIRC jumps to it automatically if there is an error) but like any goto label, if the script doesn't /return before it reaches that point, whatever follows will still be executed.
For example, this will echo the error line even though there is obviously no error
alias sparta1 {
noop
:error
echo -ag Error: [sparta1]
reseterror
}
This time because we check that there is an error, it won't.

alias sparta2 {
noop
:error
if ($error) {
echo -ag Error: [sparta2]
reseterror
}
}
The /reseterror command must come after you check for $error.