× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The way that function calls work is if you do not pass an error data
structure, the system will signal an error back which you can catch with
a Monitor but if you include the data structure, or at least one with
space for the error codes, and an error occurs, the function traps the
message and puts the error message id associated with the error into the
data structure for return.

That is probably why you are not getting back a %Error. It does not
return an error. You just need to check the data structure to see if an
error has been returned. 

Standard copy block

d StdErrorModel...                                              
d                 ds                  Qualified
d   Size...                                                     
d                                     Like(StdInt)              
d                                     Inz(%Size(StdErrorModel)) 
d   BytesAvailable...                                           
d                                     Like(StdInt)              
d                                     Inz(*Zero)                
d   MessageId...                                                
d                                     Like(StdMsgId)            
d                                     Inz(*Blank)               
d   Reserved1...                                                
d                                     Like(StdChr)              
d                                     Inz(*Blanks)              
d   MessageData...                                              
d                             1024    Inz(*Blanks)              

Variable declaration.

d ApiError...                                                 
d                 ds                  LikeDs(StdErrorModel)   
 /Free

  ActivationMark = QleActBndPgm(SystemPointer:           
                                *OMIT        :           
                                *OMIT        :           
                                *OMIT        :           
                                ApiError     );          
  If ApiError.BytesAvailable > 0;                        
    ERRH_Throw(ApiError.MessageId  :                    
               cCPFMessageFileName :                    
               ApiError.MessageData);                   
  EndIf;                                                  


Now when I debug my program, the %Error IF statement shows no error,
however ERRC0100 does show that there was an error, and MsgId
contains
the message ID that I am looking for.
 
So, why does the CallP(e) not trigger the %Error any more? And
second,
and probably more important, what is the "correct" way to accomplish
what I am trying to do?


Not quite sure about your second question here. Are you asking how you
should do error handling on API calls?

If that is the question, I think the best is to pass the API error
structure and get back the error. That way you get back a specific error
message. 

If the question is how you should do error handling and specifically how
to return errors to the caller, the solution I recommend is a general
purpose error handler. 

My XVERRH service program is one and is available freely. I never return
error from caller unless it is inside my own code. The problem with
returning same value is that somebody has to look at it and people don't
look at it. 

ERRH_Throw throws an error message to the caller just like IBM does. In
the caller, you monitor for an error and capture the error. If you don't
monitor it stops the program just like an IBM error does. 

        Monitor;

          VariablePointer = GetAVariablePointer(InActivationMark
:    
 
LowerToUpperCase(InVariableName));  
        On-Error;

          ERRH_GetLastMessage(MessageId       :

                              qMessageFileName:

                              MessageData     );

          ERRH_Throw(MessageId       :

                     qMessageFileName:

                     MessageData     );

        EndMon;


I use a standard error handler for everything I can. Makes my code a lot
simpler. 

So, why does the CallP(e) not trigger the %Error any more? And
second,
and probably more important, what is the "correct" way to accomplish
what I am trying to do?




As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.