home > 比較編 > Perl, PHP, Python, Ruby > execution control >

ForNext

Only Do What Only You Can Do

164. catch exception

VBScript

JScript

Perl

eval { risky };
if ($@) {
  print "risky failed: $@\n";
}



PHP

try {
  risky();
} catch (Exception $e) {
  echo "risky failed: ",
    $e->getMessage(), "\n";
}

Python

try:
  risky()
except:
  print('risky failed')



Ruby

# catches StandardError
begin
  risky
rescue
  print "risky failed: "
  puts $!.message
end

PowerShell

Scala

F#

C

C++

C++Builder

VC++

C#

Java

Objective-C

D

VB

VB.NET

Delphi

Ada

PL/SQL

T-SQL

関数型

inserted by FC2 system