presto-main/src/main/java/io/prestosql/sql/planner/ExpressionInterpreter.java/ExpressionInterpreter/createFailureFunction
class ExpressionInterpreter:    private static Expression createFailureFunction(RuntimeException exception, Type type, Metadata metadata)
    {
        requireNonNull(exception, "Exception is null");

        String failureInfo = JsonCodec.jsonCodec(FailureInfo.class).toJson(Failures.toFailure(exception).toFailureInfo());
        FunctionCall jsonParse = new FunctionCallBuilder(metadata)
                .setName(QualifiedName.of("json_parse"))
                .addArgument(VARCHAR, new StringLiteral(failureInfo))
                .build();
        FunctionCall failureFunction = new FunctionCallBuilder(metadata)
                .setName(QualifiedName.of("fail"))
                .addArgument(JSON, jsonParse)
                .build();

        return new Cast(failureFunction, toSqlType(type));
    }