Struggling to debug this one.

The full log is as follows:

```
Next exception 'Twig_Error_Runtime' with message 'An exception has been thrown during the rendering of a template ("") in "book/poll-availability" at line 4.' in /var/www/craft/app/vendor/twig/twig/lib/Twig/Template.php:355
Stack trace:
#0 /var/www/craft/app/vendor/twig/twig/lib/Twig/Template.php(314): Twig_Template->displayWithErrorHandling(Array, Array)
#1 /var/www/craft/app/vendor/twig/twig/lib/Twig/Template.php(325): Twig_Template->display(Array)
#2 /var/www/craft/app/vendor/twig/twig/lib/Twig/Environment.php(293): Twig_Template->render(Array)
#3 /var/www/craft/app/services/TemplatesService.php(223): Twig_Environment->render('book/poll-avail...', Array)
#4 /var/www/craft/app/controllers/BaseController.php(74): Craft\TemplatesService->render('book/poll-avail...', Array)
#5 /var/www/craft/app/controllers/TemplatesController.php(55): Craft\BaseController->renderTemplate('book/poll-avail...', Array)
#6 [internal function]: Craft\TemplatesController->actionRender('book/poll-avail...', Array)
#7 /var/www/craft/app/framework/web/actions/CAction.php(109): ReflectionMethod->invokeArgs(Object(Craft\TemplatesController), Array)
#8 /var/www/craft/app/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal(Object(Craft\TemplatesController), Object(ReflectionMethod), Array)
#9 /var/www/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#10 /var/www/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#11 /var/www/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#12 /var/www/craft/app/framework/web/CWebApplication.php(282): CController->run('render')
#13 /var/www/craft/app/framework/web/CWebApplication.php(141): CWebApplication->runController('templates/rende...')
#14 /var/www/craft/app/etc/web/WebApp.php(279): CWebApplication->processRequest()
#15 /var/www/craft/app/framework/base/CApplication.php(184): Craft\WebApp->processRequest()
#16 /var/www/craft/app/index.php(62): CApplication->run()
#17 /var/www/public-imperialhotels/en/index.php(22): require_once('/var/www/craft/...')
#18 {main}
REQUEST_URI=/en/book/poll-availability?token=9923444c-13b4-41bb-b7ab-9e339277bacc&iframe=true&room-urns=

```

And the template in question looks like this:

```
{% set token = craft.request.getParam('search') %}

{% if (not craft.request.isAjax and not token ) %}
    {% exit 404 %}
{% endif %}

{% hook 'microsGetAvailabilityResults' %}

{% header 'Content-Type: application/json' %}

{% set data = {
    'complete': results.complete,
    'urn': results.urn,
    'pollUrl': craft.request.url ~ '?' ~ craft.request.queryStringWithoutPath
} %}

{{ data | json_encode | raw }}

```

So line 4 specifically is this:

```
    {% exit 404 %}

```

That should only be called if `token` is blank and as you can see from the `REQUEST_URI`, it should be set:

```
REQUEST_URI=/en/book/poll-availability?token=9923444c-13b4-41bb-b7ab-9e339277bacc&iframe=true&room-urns=

```

Any suggestions?

What's most frustrating is that this has been picked up in server log monitoring on a live box and we can't replicate it.

The template exits correctly if we hit the URL with a non-Ajax request and if no token is defined, so what gives?