New to working with DOH - Forum - OpenEdge General - Progress Community
 Forum

New to working with DOH

This question is not answered

I'm new to working the Dynamic Object Handler, using the Spark framework.  My question is how can I pretty up an error being thrown from with in the application, in this case from the InvokingHandler event?  One class into the InvokingHandler, from ::establishRequestEnvionment, (the first statement:UNDO, THROW NEW Progress.Lang.AppError("My Test error.", 0) ), I throw an Progress.Lang.App error which is caught by the InvokingHandler catch block.  A generic 500 error gets returned to the client.  I want to be able to pretty up the error message and give more detail, but I cannot seem to find from where that error message is being generated.  I've traced calls back into the OpenEdge.Web.DataObject.DataObjectHandler but get lost from there.  Any help would be appreciate. 

{
    "error_code": 500,
    "status_txt": "500 - Server Error: the server could not produce a response entity due to an internal error - GET /myapp/web/api/printers/printers/fetchprinters",
    "error_details": {
        "remote_user": "null",
        "user_principal": "null",
        "url_scheme": "http",
        "remote_addr": "0:0:0:0:0:0:0:1",
        "server_name": "localhost",
        "product_type": "dev",
        "http_status": 500,
        "error_detail": ""
    },
    "debug_details": {
        "http_method": "GET",
        "web_application": "/myapp",
        "transport": "OEWebServlet",
        "request_url": "/myapp/web/api/printers/printers/fetchprinters",
        "path_info": "null",
        "servlet": "OEWebServlet",
        "uri": "/myapp/web/api/printers/printers/fetchprinters",
        "exception_class": "",
        "exception_message": "",
        "exception_stack_trace": ""
    }
}
 
 
The InvokingHandler code:

method private void InvokingHandler ( input poSender as Progress.Lang.Object,
input poEventArgs as OperationInvocationEventArgs ):
assign dInvokeTime = now. /* Remember when we start execution. */

/* Determine the target type of the entity. */
define variable oTargetType as TargetTypeEnum no-undo.
assign oTargetType = TargetTypeEnum:GetEnum(poEventArgs:Operation:TargetType).

if poEventArgs:Operation:ServiceURI eq "/" then
oLogger:Debug(substitute("INVOKING - &1 '&2' [&3]",
string(poEventArgs:Operation:Method),
poEventArgs:Service:Name,
poEventArgs:Operation:TargetName)).
if oTargetType eq TargetTypeEnum:Procedure then
oLogger:Debug(substitute("INVOKING - &1 /&2 &3 -> '&4' in &5",
string(poEventArgs:Operation:Method),
poEventArgs:Service:Name,
poEventArgs:Operation:ServiceURI,
poEventArgs:Operation:TargetFunction,
poEventArgs:Operation:TargetName)).
else
oLogger:Debug(substitute("INVOKING - &1 /&2/&3 -> &4:&5",
string(poEventArgs:Operation:Method),
poEventArgs:Service:Name,
poEventArgs:Operation:ServiceURI,
poEventArgs:Operation:TargetName,
poEventArgs:Operation:TargetFunction)).

/**
* Assert the current user's identity for this session request.
*
* Note: For working with anonymous security, ensure the following are set:
* OEClientPrincipalFilter.anonymous=true
* OEClientPrincipalFilter.sealAnonymous=true
* OEClientPrincipalFilter.passthru=true
*/
assign oPrincipal = OpenEdge.Security.Principal:Import(session:current-request-info).
Ccs.Common.Application:SessionManager:establishRequestEnvironment(oPrincipal:Token).

catch err as Progress.Lang.Error:
assign poEventArgs:Error = err.
oLogger:Error(substitute("INVOKING - &1: &2", poEventArgs:Operation:TargetName, err:GetMessage(1))).
end catch.

end method. /* InvokingHandler */

All Replies
  • What version are you using? There was a bug (or two) fixed in the next 11.7.x and 12.x versions relating to error handling from the DOH. It looks like OCTA-19471 (DOH's OnLoadEntity event doesn't throw errors from events) is the one you're running into, although there's a chance it was OCTA-19465 (DOH does not treat SendExceptionErrors same as other errors in PerformOperation).
     
    In currently-available versions, there are basically 3 cases where a 500 is returned to the client
    - A SendExceptionError is raised somewhere in the PerformOperation method (which is the code that starts the 'business entities' , runs the operation in them, and stops them).
    - Some error is raised in the error handling code (in the OperationError event handlers and/or the DOH's HandleException code)
    - Some code has set one of the event args' ReturnStatusCode propery to 500
     
    There logging for each of those cases, but at a guess I'd say you running into the second one.
     
    Does anything change if you re-throw 'err' from this block?

    catch err as Progress.Lang.Error:
    assign poEventArgs:Error = err.
    oLogger:Error(substitute("INVOKING - &1: &2", poEventArgs:Operation:TargetName, err:GetMessage(1))).
    end catch.

     
    It may be worth contacting TS , especially if that doesn't work. At the very least we can verify that the fixes for those bugs solve your problem.
     
     
  • Sorry, I didn't specify the version, it's 11.7.5

  • No, re-throwing the error results in the same message.