This topic describes error handling in the PHP runtime environment.

Function Compute captures exceptions that occur when you invoke a PHP function and returns information about the exceptions. In the following sample code, the information about the oops exception is returned.

<?php
function handler($event, $context) {
  throw new Exception("oops");
}

The system returns the following response when you invoke the function:

{
    "errorMessage":"oops",
    "errorType":"Exception",
    "stackTrace":{
        "file":"/code/index.php",
        "line":3,
        "traceString":""
    }
}

If an exception occurs, the HTTP header in the response contains X-Fc-Error-Type: UnhandledInvocationError. For more information about the error types in Function Compute, see Error handling.