C++
try {
  if (b == 0)
    throw 1;
  x = a / b;
} catch (int e) {
  cout << "b=0";
}
Java
try {
  x = a / b;
} catch (Exception e) {
  System.out.println("b=0");
}
JavaScript
try {
  x = a / b;
} catch (e) {
  alert("b=0");
}
Moo
try
  x = a / b;
except (E_DIV)
  player:tell("b=0");
endtry
PHP
try {
  $x = $a / $b;
} catch (Exception $e) {
  echo "b=0";
}
Python
try:
  x = a / b
except ZeroDivisionError:
  print "b=0"
QuickBasic
ON ERROR GOSUB trap
x = a / b
ON ERROR GOTO 0
END
trap:
PRINT "b=0"
RESUME