---
name: "ns_adp_abort"
section: "3aolserver"
platform: "linux"
package: "aolserver4-dev"
version: "4.5.1-18.1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/ns_adp_abort"
---

# ns\_adp\_abort(3aolserver)

ADP exception handling

```

```

## NAME

ns\_adp\_abort, ns\_adp\_break, ns\_adp\_exception, ns\_adp\_return - ADP exception handling

## SYNOPSIS

```
ns_adp_abort ?result?
ns_adp_break ?result?
ns_adp_exception ?varName?
ns_adp_return ?result?
```

```

```

## DESCRIPTION

These commands enable early return and interrupt of an ADP execution. Internally, the exception routines sets a flag and return TCL\_ERROR to begin unwinding the current Tcl call stack and return control to the ADP evaluation engine.  It is possible for an enclosing **catch** command to catch the exception and stop Tcl from returning control to ADP.  The **ns\_adp\_exception** command can be used to test for this condition.

- **ns\_adp\_abort** ?*result*?

  This command stops ADP processing, raising an execution and unwinding the stack to the top level as an error condition.  The request handling code which invokes the first ADP file will normallly generate an error message in this case, ignoring the contents of the output buffer, if any.  Note that the exeception can be caught by a **catch** command in script block which executes **ns\_adp\_abort**. However, when that block returns control to the ADP execution engine, the stack will be continue to be unwound.  The optional *result* argument, if present, will be used to set the Tcl interpreter result string.

- **ns\_adp\_break** ?*result*?

  This command stops execution of ADP and unwinds the ADP call stack. Unlike **ns\_adp\_abort**, the request handling code will generate a normal HTTP response with any contents of the output buffer.  The optional *result* argument, if present, will be used to set the Tcl interpreter result string.

- **ns\_adp\_exception** ?*varName*?

  This command returns a boolean value if an exception has been raised. The optional *varName* provides the name of a variable to store one of *ok*, *break*, *abort*, or *return* to indicate the type of exception raised.

- **ns\_adp\_return** ?*result*?

  This function halts processing of the current ADP and sends any pending output (from ns\_adp\_puts or static HTML) up to the point where it was called to the browser. Nothing in the current ADP is output or executed after it is called.  The *return\_value*, if specified, becomes the return value of the ADP.  Note that this function returns only one level up the call stack.  By contrast, **ns\_adp\_abort** and **ns\_adp\_break** will return all the way up the call stack.  **ns\_adp\_return** is typically used from an ADP included by another ADP, to stop processing of the inner ADP while allowing the calling ADP to continue.  The optional *result* argument, if present, will be used to set the Tcl interpreter result string.

## EXAMPLE

The following example demonstrates halting execution of the ADP after returning a complete response with one of the **ns\_return** style commands:

```
<%
if !$authorized {
	ns_returnunauthorized; # Send complete response.
	ns_adp_abort; # Execution stops here.
}
%>.
```

## SEE ALSO

ns\_adp(n)

## KEYWORDS

ADP, dynamic pages, exception
