IBM AS/400 manual ILE RPG Exception Handling, Exception Handling Overview, Main

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 244
Image 244

Exception Handling Overview

tion. If it remains unhandled, then the entry is removed and the func percolated. The process repeats until the exception is handled.

In

ILE,

 

an

exception message is associatprocedurewithwhichtheis

active

on

 

 

 

the call stack. When the exception is notpercolated,converted

toit

ais function

 

 

 

check.

Each

call

stack

entry is given a

chance

to

handle

the

original

the control boundary is reached. Only then is

the

exception converted

check,

at which

point

the

exception

processing

starts

all

over

again

b

the

procedure which

received

the

exception.

This

time

 

each

call

sta

a

chance

to

handle the function check. If the

control

boundary

is

re

exception

is

still unhandled then a generic failure exception

message

C

sent

to

 

the

caller of the procedure at the

control

boundary.

In

ad

stack

entry

which

did not

to

handle

the

message

is

removed.

 

 

 

 

ILE RPG Exception Handling

ILE RPG provides three types of exception handling mechanisms:

¹ An error indicator or an 'E' operation code extender handler

¹ An error subroutine handler

¹A default exception handler

RPG categorizes exceptions into two classes,

program

and

file;

this

de

which type of error subroutine is called.

Some

examples

of program

ex

division by zero, out-of-bounds array index,

or SQRT of a negative numb

examples of file exceptions are undefined

record type or a device

There

are

four

ways

for

you

to

 

indicate

that

 

RPG

should

handle

an

e

can:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1. Specify

an

error

indicator

in

positions

73

-

74

of

the

calculation

the

appropriate operation

code.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2. Specify

the

operation

code

extender

'E'

for

 

the

appropriate

opera

3. Code a file error subroutine, which is

defined by the INFSR keyw

description

specification,

for

file

exceptions.

The

file

error

subr

be

coded

in

the

main

source

section.

You

cannot

code

an

INFSR

for

is

used

in

a

subprocedure.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4. Code a program error subroutine, which is named *PSSR, for program

 

exceptions. Note that a *PSSR

is

local

to

the procedure in which it

This means that a *PSSR in a

main

procedure

will

handle

only

those

pr

errors associated with the main procedure. Similarly,

a

*PSSR

in

a

su

dure will

only

handle the

errors

in

that

subprocedure.

 

 

 

 

Exception

Handling within

a

Main

Procedure

 

 

When

an

exception

occurs

within

a main

procedure ILE RPG

does the fo

1. If

an

error

indicator

is

present

on the calculation

specification

is

one

that is expected for that

operation:

 

a. The

indicator

is

set on

 

 

 

b. The exception is handled

c. Control resumes with the next ILE RPG operation.

220 ILE RPG for AS/400 Programmer's Guide

Page 244
Image 244
IBM AS/400 manual ILE RPG Exception Handling, Exception Handling Overview, Main