# Evaluation throws an exception

Source: https://findproxyforurl.net/rules/runtime-exception/ · last updated 2026-10-11

Rule PAC-E006 (`runtime-exception`), severity high, category: Errors and robustness.

A test evaluation ended with an uncaught exception instead of a return value. The engine treats this as a script failure for that request.

## Why it matters

This is the observed counterpart of static findings such as PAC-E005: for at least one of
the test URLs the function threw instead of returning. Engines do not retry or use a later
branch; the request is handled as if the PAC failed. In Chromium and Firefox that means a
direct connection. Windows (WinHTTP) returns an error to the program that asked; in the lab
(2026-10-11) programs built on .NET Framework and .NET 8 then went direct without showing an
error. If the exception is only thrown for some hosts, the PAC "works" in a
quick manual test and fails in production for exactly those hosts.


## How to fix

Look at the exception detail and the deciding line; common causes are undefined functions, typos in variable names and calling methods on undefined.

## Bad

```js
function FindProxyForURL(url, host) {
  var parts = host.split(".");
  if (parts[parts.length - 1] == "test" && undefinedList.indexOf(host) >= 0) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
var directHosts = ["intranet.test", "wiki.test"];
function FindProxyForURL(url, host) {
  if (directHosts.indexOf(host) >= 0) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- winhttp: An exception gives the calling program an error instead of a proxy list. .NET Framework and .NET 8 programs then connected directly without showing an error. (source: lab, verified 2026-10-11)
