Πρόταση Resume
Επαναφέρει τις πληροφορίες σφάλματος και δείχνει τι θα εκτελεστεί μετά.
Resume [ [0] | label | Next ]
0: Επαναφέρει τις πληροφορίες σφάλματος και επανεκτελεί την οδηγία που προκάλεσε το σφάλμα. Το 0 είναι προαιρετικό.
ετικέτα:: Επαναφέρει τις πληροφορίες σφάλματος και συνεχίζει την εκτέλεση στην καθορισμένη ετικέτα της τρέχουσας υπορουτίνας.
Next: Επαναφέρει τις πληροφορίες σφάλματος και εκτελεί την οδηγία ακολουθώντας αυτήν που προκάλεσε το σφάλμα.
Οι πληροφορίες σφάλματος είναι δομημένες με τις συναρτήσεις Erl, Err και Error$.
Erl: Αριθμός γραμμής αρθρώματος όπου εμφανίζει το σφάλμα.
Err: Αριθμός σφάλματος.
Error[$]: Περιγραφή σφάλματος.
Using Resume to reset error information prevents the propagation of the handled condition to calling routines.
Examples:
Typical error handling routines are: alerting the user, fixing the error, logging error information or re-throwing custom errors that provide explanations with resolution instructions. Use Resume label when requiring such mechanisms.
Sub Error_Handling
try: On Error GoTo catch
' routine code goes here
Error 91 ' example error
finally:
' routine cleanup code goes here
Exit Sub
catch:
Print Erl, Err, Error$
Resume finally
End Sub ' Error_Handling
Use Resume Next, for example, when reporting anomalies encountered for an iterating process that must not be interrupted. In which case multiple handling routines may be required.
Sub Iteration
planets = Array("☿","♀","♁","♂","♃","♄","⛢","♆")
try:
On Error GoTo ReportAndProcessNext
For ndx = -3 To 11 Step 1
MsgBox planets(ndx)
Next
On Error GoTo 0 ' Stop error catching
finally:
Exit Sub
ReportAndProcessNext:
Print "Error "& Err &" at line "& Erl &" - "& Error$
Resume Next
End Sub ' Iteration
Using Resume without parameters to re-execute the faulty instruction can fit certain situations. However that may cause a neverending loop.