ASP Classic:
On Error
Syntax Example:
On Error Resume Next Response.Write FormatDateTime(f_CurrentActualDate, vbShortDate) If ErrNumber <> 0 Then Break(f_CurrentActualDate) End If On Error Goto 0
C#:
try...catch...finally
C# uses a try...catch...finally statement to trap for errors.
try {} catch {} finally {}
Syntax Example: try { int y = 0; y = 1 / y; } catch { MessageBox.Show("you cannot divide by zero"); }
C++:
try/catch
Corel Paradox:
try...onFail
ObjectPAL has a try...onFail statement but does not have a finally-type component. However, the code afer endTry will execute.
try onFail endTry
Syntax Example:
var i SmallInt endVar try i = 0 i = 1/i onFail msgInfo("", "You cannot divide by zero.") endTry
Delphi:
try..except, try..finally
Use a try..except..end block to trap and process errors.
Delphi also offers a try...finally where code will execute in the finally section no matter what. It's common to put a try..except inside a try..finally .
Syntax Example:
var y : Double; begin try y := 0; y := (1/y); ShowMessage(FloatToStr(y)); except ShowMessage('You cannot divide by zero.'); end ; end;
Delphi Prism:
try..except, try..finally
Use a try..except..end block to trap and process errors.
Delphi also offers a try...finally where code will execute in the finally section no matter what. It's common to put a try..except inside a try..finally .
Syntax Example:
try var y: Integer; y := 0; y := 1/y;except MessageBox.Show("You cannot divide by zero.");end ;
Java:
try/catch/finally
Syntax Example:
try { /* Risky code here. */ } catch (SomeException) { //one or more. /* Recovery here. */ } finally { //0 or one. /* Do something. */ }
JavaScript:
try/catch/finally
See "throw" to raise (throw) an error.
Syntax Example:
try { //Do something. } catch(e) { //one or more. //Do something. } finally { //0 or one. //Do something. }
VB.Net:
Try...Catch...Finally
VB.Net uses a try...catch...finally statement to trap for errors.
Try Catch Finally End Try
Syntax Example: Try Dim y As Integer = 0 y = 1 / y Catch MessageBox.Show("you cannot divide by zero") End Try