You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Tony Hoyt <gm...@yahoo.com> on 2008/11/12 23:57:29 UTC

Custom Error Messages

This is a topic that seems to come up every now and then but, I haven't seen a solution posted that works with the more recent 1.5.0 release of Axis2/C.  Using wsdl2c generated code, I want to send back to clients a custom error message but, I haven't found a way to do so yet.  Currently, It appears that I could use the following functions, but when I set the values and return NULL in my custom operation code, the client doesn't get the error I've been expecting.

== Code Start ==
adb_myResponse_t *axis2_skel_myService_myOp 
  (const axutil_env_t *env, adb_myRequest_t* myRequest )
{
 axutil_error_set_error_message( env->error, 
  "This is my custom error message..." );
 AXIS2_ERROR_SET( env->error,  
  (enum axutil_error_codes)(AXIS2_ERROR_LAST + 1), AXIS2_FAILURE );
 return NULL;
}
== Code End ==

How do I send a custom error message back to the client to warn the user of a potential error in Axis2/C?

  Tony



"Opportunities multiply as they are seized." - Sun Tzu



      

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: Custom Error Messages

Posted by Tony Hoyt <gm...@yahoo.com>.
--- On Wed, 11/12/08, Dinesh Premalal <xy...@gmail.com> wrote:
> http://nethu.org/2008/01/18/axis2c-custom-error-handling/

I tried your example and it wouldn't work for me, namely because the compiler could not link up the axutil_error_messages array in src\error.c. I figure this might be a C++ issue, since that's the platform I'm working on, but that's not important at the moment.

I did manage to get the following three lines to work..

axutil_error_set_error_message( env->error, 
  "This is my custom error message..." );
AXIS2_ERROR_SET(env->error, 
  (enum axutil_error_codes)(AXUTIL_ERROR_MAX + 1), AXIS2_FAILURE);
return NULL;

BUT, to do this with code generated by WSDL2C, I had to edit the axis2_svc_skel_myService_invoke() generated function.  In this invoke function, it calls all the operations and looks to see if the return value is NULL.  If it is NULL, it sets it's OWN error message, and returns that to the user.  This is undesirable behavior for me,  I would like it if the invoke() call could check to see if the user has already set an error message.  If not, then set it's own error message, else, it would pass the user generated error message down and eventually back to the user.

As such, their should be some kind of axutil_error_get_error_number() function, that allows the user to see if an error code has been set.

Otherwise, I can hack the generated code for now, but in the future, I would have rather had the system just allow me to specify my own error messages back to the user.

  Tony

"Opportunities multiply as they are seized." - Sun Tzu





      

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org


Re: Custom Error Messages

Posted by Dinesh Premalal <xy...@gmail.com>.
Tony Hoyt <gm...@yahoo.com> writes:

> How do I send a custom error message back to the client to warn the
> user of a potential error in Axis2/C?
http://nethu.org/2008/01/18/axis2c-custom-error-handling/

thanks,
Dinesh

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-user-help@ws.apache.org