Receiving Error Conditions as Exceptions—Example

This example shows an application that receives error conditions as e allocates an error code parameter that is a minimum of 4 bytes long bytes provided field. The only field used is the bytes-provided I the application sets to zero to request exceptions. The error code tains the following:

Field

INPUT

OUTPUT

 

 

 

Bytes provided

0

0

 

 

 

Receiving

the

 

Error

Code

without

the

 

Exception

Data—Example

 

 

 

 

 

 

 

 

 

 

This application example attempts to create an

alert

for

message

ID

message file USRMSG in library

QGPL. It

receives

the

error

 

condition

code

 

parameter

but

does

not

receive

any

exception

data. To

do

thi

error

code

parameter

that

is

 

a minimum

of

16

 

bytes

long—for

the

 

by

bytes

available,

exception

ID,

and

reserved

fields. It

sets

the

b

the

error

 

code

parameter

to

16.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When

the

application

 

calls

the

 

Generate

Alert

(QALGENA)

API,

the

alert

USRMSG

 

is not found, and QALGENA

returns

 

exception

 

 

CPF7B03. The

error

 

 

code parameter contains the data shown

in

the

 

 

following table. In

 

th

bytes

are

provided

 

for data,

but

36

are

available. Twenty more

 

by

be returned if the bytes-provided field

were

set

to

reflect

a

l

eter

 

(see

“Receiving

the

Error

Code

 

with

the

 

 

Exception

Data—Example”

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Field

 

 

 

 

 

 

 

 

 

 

 

INPUT

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bytes

provided

 

 

 

 

 

 

 

16

 

 

 

 

16

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bytes

available

 

 

 

 

 

 

 

Ignored

 

 

 

36

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Exception

ID

 

 

 

 

 

 

 

Ignored

 

 

 

CPF7B03

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Reserved

 

 

 

 

 

 

 

 

 

Ignored

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Receiving

the Error

Code

with the

Exception Data—Example

 

 

This application example attempts to create an alert for

message

ID

message file USRMSG

in library QGPL. It receives the error condition

code

parameter

and

receives

exception data as well. To

do this,

it

error code parameter that is 116 bytes long—16 bytes for the byt available, exception ID, and reserved fields, and 100 bytes for th for the exception. (In some cases, the exception data might be a directory or file name, so this might not be large enough to hold whatever fits is returned in the error code parameter.) Finally, it provided field to 116.

When the application calls the Generate Alert (QALGENA) API, the alert USRMSG is not found, and QALGENA returns exception CPF7B03. The error code parameter contains the following:

Field

 

INPUT

 

OUTPUT

 

 

 

 

 

 

 

Bytes

provided

116

 

116

 

 

 

 

 

 

 

Bytes

available

Ignored

 

36

 

 

 

 

 

 

 

 

 

Chapter 2.

Getting Started with2-9APIs

Page 29
Image 29
IBM Version 4 manual Receiving Error Conditions as Exceptions-Example, With Exception Data-Example, Code