Search code examples
nginxdockerhhvmhacklang

hhvm hack lang error 500 instead error report


I played around with hack on an nginx dockered service. Everything is fine instead of provoke errors. For example this function:

echo add_one("1");

function add_one(int $x): int {
  return $x+1;
}

This should produce an error because it is no integer. But instead returning the error message I get an 500 page.

Typing hhvm index.hh to the console gaves me:

Catchable fatal error: Argument 1 passed to add_one() must be an instance of int, string given in /var/www/index.hh on line 7

How can I avoid the 500 page and print this error message instead?


Solution

  • HHVM partially supports PHP's display_errors INI option. HHVM accepts the same INI format as PHP does, so the documentation above is useful for HHVM too. The HHVM INI tends to live in /etc/hhvm, but it depends on how you built and installed HHVM.

    The support is partial though, and so depending on your exact configuration and what error you hit, it may not actually have effect.. It's much better practice to read the error logs out of HHVM directly. (It also is much less confusing in the presence of a partially-rendered page.) The error logs tend to live in /var/log/hhvm, though again heavily depends on how you built and installed HHVM.

    The "Getting Started" page has information on how to get into our best-supported configuration, and where the INI and log files will live if you do that. It also has information on how to run the Hack typechecker, a necessity if you are writing Hack code.