Skip to content

Instantly share code, notes, and snippets.

@jazzdan
Created July 15, 2015 20:09
Show Gist options
  • Save jazzdan/1672598faa14b7c7c2a8 to your computer and use it in GitHub Desktop.
Save jazzdan/1672598faa14b7c7c2a8 to your computer and use it in GitHub Desktop.
<?hh
interface ExceptionWithCode {
public function getCode();
}
class Checkout_Exception extends Exception implements ExceptionWithCode {
protected $data = [];
public function __construct($msg = "", $code = 0, $data = []) {
$this->data = $data;
parent::__construct($msg, $code);
}
}
class Foo {
public function herp() {
try {
$x = 1 + 1;
} catch (ExceptionWithCode $e) {
throw new Checkout_Exception('hello', 42);
}
}
}
@jazzdan
Copy link
Author

jazzdan commented Jul 15, 2015

Output:

test.hh:20:11,27: Invalid exception (Typing[4110])
  test.hh:20:11,27: This is an object of type Exception because it is used as an exception
  test.hh:20:11,27: It is incompatible with an object of type ExceptionWithCode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment