1. stopped

Executes an object with error catching capability.

1.1. Syntax

any stopped → bool

1.2. Stack Effects

Table 1. Before
Level Object

0

any (object to execute - typically procedure)

Table 2. After (normal completion)
Level Object

(varies)

Results from execution

0

false

Table 3. After (stopped)
Level Object

(varies)

Partial results from execution

0

true

1.3. Description

stopped executes any (typically a procedure).

  • If any runs to completion normally: returns false

  • If any terminates via stop: returns true

Regardless of outcome, execution resumes at the next object after stopped.

This provides PostScript’s primary error-catching mechanism.

1.4. PostScript Level

Level 1 and later

1.5. Examples

Basic error catching
{
  % Code that might fail
  10 0 div
} stopped {
  % Error occurred
  (Division error caught) print
} if
Normal completion
{
  1 2 add
} stopped
% Returns: 3 false (normal completion)
Explicit stop
{
  errorCondition { stop } if
  normalCode
} stopped {
  (Stopped explicitly) print
} if

1.6. Common Use Cases

1.6.1. Error Handler Pattern

{
  % Main code
  riskyOperation
} stopped {
  % Error handler
  handleerror
} if

1.6.2. Try Multiple Methods

{
  % Try preferred method
  preferredMethod
} stopped {
  % Try fallback
  { fallbackMethod } stopped {
    % Last resort
    defaultMethod
  } if
} if

1.6.3. Resource Cleanup

file (r) file
{
  % Process file
  { processFile } stopped {
    file closefile  % Cleanup
    stop  % Re-raise error
  } if
} stopped {
  % Outer error handler
} if
file closefile  % Always close

1.7. Common Pitfalls

Catches All Errors - stopped catches ALL errors, including those you might not expect.
{
  typoError  % Undefined name
  realCode
} stopped pop
% Error silently caught!
Stack State - Operand and dict stacks not automatically cleaned on stop.
{
  1 2 3
  stop
} stopped {
  % Stack still contains: 1 2 3
  clear  % Must clean up manually
} if
Standard Error Pattern - Default PostScript error handlers use this pattern.

1.8. Error Conditions

Error Condition

[stackunderflow]

No operand on stack

1.9. Implementation Notes

  • Creates new execution context

  • Execution stack level saved

  • Operand/dictionary stacks not affected by unwinding

  • PostScript’s exception handling mechanism

1.10. Standard Error Handler

The default error handler uses stopped:

% Simplified version
{
  % User code
} stopped {
  handleerror
} if

1.11. Advanced Pattern

Nested error handling
{
  % Outer try
  {
    % Inner try
    criticalOperation
  } stopped {
    % Handle inner error
    recoverFromCritical
    stop  % Propagate to outer
  } if

  normalContinuation
} stopped {
  % Handle outer error
  finalRecovery
} if

1.12. See Also

  • stop - Terminate stopped context

  • exit - Exit loop

  • exec - Execute object

  • Error Handling (to be documented)


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.