You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/12/09 22:36:04 UTC
svn commit: r485063 - in /webservices/axis2/trunk/c:
modules/core/engine/Makefile.am modules/core/engine/disp_checker.c
modules/core/receivers/raw_xml_in_out_msg_recv.c util/include/axis2_error.h
util/src/error.c
Author: dinesh
Date: Sat Dec 9 13:36:02 2006
New Revision: 485063
URL: http://svn.apache.org/viewvc?view=rev&rev=485063
Log:
fixed:axis2c-381 and axis2c-328 , related to custom soap faults and giving proper soap faults
Modified:
webservices/axis2/trunk/c/modules/core/engine/Makefile.am
webservices/axis2/trunk/c/modules/core/engine/disp_checker.c
webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c
webservices/axis2/trunk/c/util/include/axis2_error.h
webservices/axis2/trunk/c/util/src/error.c
Modified: webservices/axis2/trunk/c/modules/core/engine/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/engine/Makefile.am?view=diff&rev=485063&r1=485062&r2=485063
==============================================================================
--- webservices/axis2/trunk/c/modules/core/engine/Makefile.am (original)
+++ webservices/axis2/trunk/c/modules/core/engine/Makefile.am Sat Dec 9 13:36:02 2006
@@ -2,7 +2,7 @@
noinst_HEADERS=axis2_event.h
libaxis2_engine_la_SOURCES=handler.c \
- conf.c \
+ conf.c \
phase.c \
disp_checker.c \
event.c \
Modified: webservices/axis2/trunk/c/modules/core/engine/disp_checker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/engine/disp_checker.c?view=diff&rev=485063&r1=485062&r2=485063
==============================================================================
--- webservices/axis2/trunk/c/modules/core/engine/disp_checker.c (original)
+++ webservices/axis2/trunk/c/modules/core/engine/disp_checker.c Sat Dec 9 13:36:02 2006
@@ -25,6 +25,8 @@
#include <axis2_op_ctx.h>
#include <axis2_svc_ctx.h>
#include <axis2_endpoint_ref.h>
+#include <axiom_soap.h>
+#include <axiom.h>
typedef struct axis2_disp_checker_impl
{
@@ -220,6 +222,10 @@
axis2_svc_ctx_t *svc_ctx = NULL;
axis2_endpoint_ref_t *endpoint_ref = NULL;
const axis2_char_t *address = NULL;
+ axiom_soap_fault_t *soap_fault;
+ axiom_soap_envelope_t *soap_envelope;
+ axiom_soap_body_t *soap_body;
+ int soap_version = AXIOM_SOAP12;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -262,6 +268,14 @@
if (!svc)
{
AXIS2_LOG_INFO(env->log, "Service Not found. Endpoint reference is : %s", (address) ? address : "NULL");
+ if (AXIS2_MSG_CTX_GET_IS_SOAP_11 (msg_ctx, env))
+ {
+ soap_version = AXIOM_SOAP11;
+ }
+ soap_envelope = axiom_soap_envelope_create_default_soap_envelope (env, soap_version);
+ soap_body = AXIOM_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+ soap_fault = axiom_soap_fault_create_default_fault (env, soap_body, "Receiver", "Service Not Found", soap_version);
+ AXIS2_MSG_CTX_SET_FAULT_SOAP_ENVELOPE(msg_ctx, env, soap_envelope);
return AXIS2_FAILURE;
}
Modified: webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c?view=diff&rev=485063&r1=485062&r2=485063
==============================================================================
--- webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c (original)
+++ webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c Sat Dec 9 13:36:02 2006
@@ -22,7 +22,7 @@
#include <axiom_soap_header.h>
#include <axiom_soap_body.h>
#include <axiom_soap_fault.h>
-
+#include <axiom_soap.h>
/************************* Function prototypes ********************************/
@@ -90,6 +90,8 @@
const axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
int soap_version = AXIOM_SOAP12;
axiom_namespace_t *env_ns = NULL;
+ axiom_node_t *fault_node = NULL;
+ axiom_soap_fault_detail_t *fault_detail;
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
@@ -196,7 +198,7 @@
}
}
else
- {
+ {
AXIS2_ERROR_SET(env->error,
AXIS2_ERROR_RPC_NEED_MATCHING_CHILD, AXIS2_FAILURE);
status = AXIS2_FAILURE;
@@ -213,9 +215,12 @@
{
skel_invoked = AXIS2_TRUE;
result_node = AXIS2_SVC_SKELETON_INVOKE(svc_obj, env, om_node, new_msg_ctx);
- AXIS2_SVC_SKELETON_FREE(svc_obj, env);
+ if (result_node)
+ AXIS2_SVC_SKELETON_FREE(svc_obj, env);
}
+
+
if (result_node)
{
if (0 == AXIS2_STRCMP(style, AXIS2_STYLE_RPC))
@@ -240,11 +245,14 @@
else
{
body_content_node = result_node;
+
}
}
else
{
status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
+ fault_node = AXIS2_SVC_SKELETON_ON_FAULT (svc_obj, env, om_node);
+ AXIS2_SVC_SKELETON_FREE(svc_obj, env);
}
}
@@ -316,6 +324,11 @@
soap_fault = axiom_soap_fault_create_default_fault(env, out_body,
fault_value_str, fault_reason_str, soap_version);
+ if (fault_node)
+ {
+ fault_detail = axiom_soap_fault_detail_create_with_parent (env, soap_fault);
+ AXIOM_SOAP_FAULT_DETAIL_ADD_DETAIL_ENTRY (fault_detail, env, fault_node);
+ }
}
if (body_content_node)
@@ -326,7 +339,7 @@
else if (soap_fault)
{
AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(new_msg_ctx, env, default_envelope);
- status = AXIS2_FAILURE; /* if there is a failure we have to return a failure code */
+ status = AXIS2_SUCCESS;
}
else
{
Modified: webservices/axis2/trunk/c/util/include/axis2_error.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axis2_error.h?view=diff&rev=485063&r1=485062&r2=485063
==============================================================================
--- webservices/axis2/trunk/c/util/include/axis2_error.h (original)
+++ webservices/axis2/trunk/c/util/include/axis2_error.h Sat Dec 9 13:36:02 2006
@@ -25,11 +25,11 @@
extern "C"
{
#endif
- /**
- * \brief Axis2 status codes
- *
- * Possible status values for Axis2
- */
+ /**
+ * \brief Axis2 status codes
+ *
+ * Possible status values for Axis2
+ */
enum axis2_status_codes
{
/** Critical Failure state */
@@ -39,11 +39,11 @@
/** Success state */
AXIS2_SUCCESS
};
- /**
- * \brief Axis2 error codes
- *
- * Set of error codes for Axis2
- */
+ /**
+ * \brief Axis2 error codes
+ *
+ * Set of error codes for Axis2
+ */
enum axis2_error_codes
{
/** No error.
@@ -54,7 +54,7 @@
to an arbitrary value as it is assumed in the implementation when mapping
error codes to error messages that the error codes are contiguous and
the last error value is always AXIS2_ERROR_LAST.
- */
+ */
/*
* Group - Common Errors
*/
@@ -107,9 +107,9 @@
/** Service not yet found */
AXIS2_ERROR_SERVICE_NOT_YET_FOUND,
- /*
- * Group - core:deployment
- */
+ /*
+ * Group - core:deployment
+ */
/* Invalid phase found in phase validation*/
AXI2_ERROR_INVALID_PHASE,
/* axis2.xml cannot be not found*/
@@ -156,9 +156,9 @@
AXIS2_PATH_TO_CONFIG_CAN_NOT_BE_NULL,
/* Invalid Service */
AXIS2_ERROR_INVALID_SVC,
- /*
- * Group - core:description
- */
+ /*
+ * Group - core:description
+ */
/* Cannot correlate message*/
AXIS2_ERROR_CANNOT_CORRELATE_MSG,
/** Could not Map the MEP URI to a axis MEP constant value */
@@ -179,9 +179,9 @@
AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE,
/* schema list is empty or NULL in svc */
AXIS2_ERROR_EMPTY_SCHEMA_LIST,
- /*
- * Group - core:engine
- */
+ /*
+ * Group - core:engine
+ */
/** Both before and after handlers cannot be the same */
AXIS2_ERROR_BEFORE_AFTER_HANDLERS_SAME,
/** Invalid handler rules */
@@ -192,7 +192,7 @@
AXIS2_ERROR_INVALID_PHASE_FIRST_HANDLER,
/** Invalid last handler for phase */
AXIS2_ERROR_INVALID_PHASE_LAST_HANDLER,
- /** Invalid engine config state */
+ /** Invalid engine config state */
AXIS2_ERROR_INVALID_STATE_CONF,
/** Message context processing a fault already */
AXIS2_ERROR_INVALID_STATE_PROCESSING_FAULT_ALREADY,
@@ -207,9 +207,9 @@
/**Two service can not have same name, a service with same name alredy
exist in the system */
AXIS2_ERROR_TWO_SVCS_CANNOT_HAVE_SAME_NAME,
- /*
- * Group - core:phaseresolver
- */
+ /*
+ * Group - core:phaseresolver
+ */
/* Invalid Module Ref */
AXIS2_ERROR_INVALID_MODULE_REF,
/* Invalid Phase */
@@ -228,9 +228,9 @@
*/
/** Schema is NULL */
AXIS2_ERROR_WSDL_SCHEMA_IS_NULL,
- /*
- * Group - core:receivers
- */
+ /*
+ * Group - core:receivers
+ */
/* Om Element has invalid state */
AXIS2_ERROR_OM_ELEMENT_INVALID_STATE,
/* Om Elements do not match */
@@ -241,13 +241,13 @@
AXIS2_ERROR_UNKNOWN_STYLE,
/* String does not represent a valid NCName */
AXIS2_ERROR_STRING_DOES_NOT_REPRESENT_A_VALID_NC_NAME,
- /*
- * Group - core:transport
- */
-
- /*
- * Group - core:transport:http
- */
+ /*
+ * Group - core:transport
+ */
+
+ /*
+ * Group - core:transport:http
+ */
/* Error occured in transport */
AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR,
/** A read attempt(HTTP) for the reply without sending the request */
@@ -298,25 +298,25 @@
AXIS2_ERROR_UNSUPPORTED_SCHEMA_TYPE,
/* Service or operation not found */
AXIS2_ERROR_SVC_OR_OP_NOT_FOUND,
- /*
- * Group - mod_addr
- */
-
- /*
- * Group - platforms
- */
+ /*
+ * Group - mod_addr
+ */
+
+ /*
+ * Group - platforms
+ */
- /*
- * Group - utils
- */
- /** Could not open the axis2 file */
- AXIS2_ERROR_COULD_NOT_OPEN_FILE,
+ /*
+ * Group - utils
+ */
+ /** Could not open the axis2 file */
+ AXIS2_ERROR_COULD_NOT_OPEN_FILE,
/* Failed in creating DLL */
AXIS2_ERROR_DLL_CREATE_FAILED,
/* DLL loading failed */
AXIS2_ERROR_DLL_LOADING_FAILED,
- /** Environment passed is null */
- AXIS2_ERROR_ENVIRONMENT_IS_NULL,
+ /** Environment passed is null */
+ AXIS2_ERROR_ENVIRONMENT_IS_NULL,
/* Axis2 File does not have a file name */
AXIS2_ERROR_FILE_NAME_NOT_SET,
/* DLL Description Info Object has invalid state */
@@ -325,12 +325,12 @@
AXIS2_ERROR_HANDLER_CREATION_FAILED,
/** Array list index out of bounds */
AXIS2_ERROR_INDEX_OUT_OF_BOUNDS,
- /** Invalid IP or hostname */
- AXIS2_ERROR_INVALID_ADDRESS,
- /** Trying to do operation on invalid file descriptor */
- AXIS2_ERROR_INVALID_FD,
- /** Trying to do operation on closed/not opened socket */
- AXIS2_ERROR_INVALID_SOCKET,
+ /** Invalid IP or hostname */
+ AXIS2_ERROR_INVALID_ADDRESS,
+ /** Trying to do operation on invalid file descriptor */
+ AXIS2_ERROR_INVALID_FD,
+ /** Trying to do operation on closed/not opened socket */
+ AXIS2_ERROR_INVALID_SOCKET,
/** Parameter not set */
AXIS2_ERROR_INVALID_STATE_PARAM,
/* Module create failed */
@@ -339,10 +339,10 @@
AXIS2_ERROR_MSG_RECV_CREATION_FAILED,
/** No such element */
AXIS2_ERROR_NO_SUCH_ELEMENT,
- /** Socket bind failed. Another process may be already using this port*/
- AXIS2_ERROR_SOCKET_BIND_FAILED,
- /** Error creating a socket. Most probably error returned by OS */
- AXIS2_ERROR_SOCKET_ERROR,
+ /** Socket bind failed. Another process may be already using this port*/
+ AXIS2_ERROR_SOCKET_BIND_FAILED,
+ /** Error creating a socket. Most probably error returned by OS */
+ AXIS2_ERROR_SOCKET_ERROR,
/* Listen failed for the server socket */
AXIS2_ERROR_SOCKET_LISTEN_FAILED,
/* Failed in creating Service Skeleton */
@@ -355,13 +355,13 @@
AXIS2_ERROR_UUID_GEN_FAILED,
/* Possible deadlock */
AXIS2_ERROR_POSSIBLE_DEADLOCK,
- /*
- * Group - wsdl
- */
+ /*
+ * Group - wsdl
+ */
/* Interface or Port Type not found for the binding */
AXIS2_ERROR_INTERFACE_OR_PORT_TYPE_NOT_FOUND_FOR_THE_BINDING,
- /* Interfaces or Ports not found for the partially built WOM */
- AXIS2_ERROR_INTERFACES_OR_PORTS_NOT_FOUND_FOR_PARTIALLY_BUILT_WOM,
+ /* Interfaces or Ports not found for the partially built WOM */
+ AXIS2_ERROR_INTERFACES_OR_PORTS_NOT_FOUND_FOR_PARTIALLY_BUILT_WOM,
/** Wsdl op accessed has invalid state */
AXIS2_ERROR_INVALID_STATE_WSDL_OP,
/** Wsdl Service accessed has invalid state */
@@ -376,17 +376,17 @@
AXIS2_ERROR_WSDL_PARSER_INVALID_STATE,
/* Wsdl svc name cannot be null(Required) */
AXIS2_ERROR_WSDL_SVC_NAME_IS_REQUIRED,
- /*
- * Group - xml
- */
-
- /*
- * Group - xml:attachments
- */
+ /*
+ * Group - xml
+ */
+
+ /*
+ * Group - xml:attachments
+ */
- /*
- * Group - xml:om
- */
+ /*
+ * Group - xml:om
+ */
/** Builder done with pulling. Cannot pull any more */
AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL,
/** Discard faile because the builder state is invalid */
@@ -400,18 +400,18 @@
/** error a namespace should have a valid uri */
AXIS2_ERROR_INVALID_EMPTY_NAMESPACE_URI,
/** next method has not been called so cannot remove
- an element before calling next valid for any om iterator */
+ an element before calling next valid for any om iterator */
AXIS2_ERROR_ITERATOR_NEXT_METHOD_HAS_NOT_YET_BEEN_CALLED,
/** remove method has alread been called once so cann't remove till
- next method is called valid for any om children iterator*/
+ next method is called valid for any om children iterator*/
AXIS2_ERROR_ITERATOR_REMOVE_HAS_ALREADY_BEING_CALLED,
/** axiom_xml_reader returned NULL element */
AXIS2_ERROR_XML_READER_ELEMENT_NULL,
/** axiom_xml_reader returned NULL value */
AXIS2_ERROR_XML_READER_VALUE_NULL,
- /*
- * Group - xml:parser
- */
+ /*
+ * Group - xml:parser
+ */
/** error occured creating xml stream reader */
AXIS2_ERROR_CREATING_XML_STREAM_READER,
/** error occured creating xml stream writer */
@@ -450,12 +450,12 @@
AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE_PREFIX,
/** error in writing cdata section */
AXIS2_ERROR_WRITING_CDATA,
- /** AXIS2_XML_PARSER_TYPE_BUFFER or AXIS2_XML_PARSER_TYPE_DOC is expected */
- AXIS2_ERROR_XML_PARSER_INVALID_MEM_TYPE,
+ /** AXIS2_XML_PARSER_TYPE_BUFFER or AXIS2_XML_PARSER_TYPE_DOC is expected */
+ AXIS2_ERROR_XML_PARSER_INVALID_MEM_TYPE,
- /*
- * Group - xml:soap
- */
+ /*
+ * Group - xml:soap
+ */
/** invalid type passed */
AXIS2_ERROR_INVALID_BASE_TYPE,
/** invalid soap namespace uri found */
@@ -490,7 +490,7 @@
/*soap11 fault actor element should not have child elements*/
AXIS2_ERROR_SOAP11_FAULT_ACTOR_SHOULD_NOT_HAVE_CHILD_ELEMENTS,
/** soap builder found a child element other than header or body in envelope
- element */
+ element */
AXIS2_ERROR_SOAP_BUILDER_ENVELOPE_CAN_HAVE_ONLY_HEADER_AND_BODY,
/** soap builder encounterd body element first and header next */
AXIS2_ERROR_SOAP_BUILDER_HEADER_BODY_WRONG_ORDER,
@@ -522,9 +522,9 @@
AXIS2_ERROR_UNSUPPORTED_ELEMENT_IN_SOAP_FAULT_ELEMENT,
/*wrong element order encounterd*/
AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED,
- /*
- * Group - services
- */
+ /*
+ * Group - services
+ */
/** Invalid XML format in request */
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
/** Input OM node NULL, Probably error in SOAP request */
@@ -532,9 +532,9 @@
/** Invalid parameters for service operation in SOAP request */
AXIS2_ERROR_SVC_SKEL_INVALID_OPERATION_PARAMETERS_IN_SOAP_REQUEST,
- /*
- * Group - repos
- */
+ /*
+ * Group - repos
+ */
/* not authenticated */
AXIS2_ERROR_REPOS_NOT_AUTHENTICATED,
/* unsupported mode */
@@ -552,14 +552,14 @@
All other error codes should appear above this.
AXIS2_ERROR_LAST is used to track the number of error codes present
for the purpose of sizing the error message array.
- */
+ */
AXIS2_ERROR_LAST
};
struct axis2_error;
struct axis2_error_ops;
- typedef enum axis2_status_codes axis2_status_codes_t;
- typedef enum axis2_error_codes axis2_error_codes_t;
+ typedef enum axis2_status_codes axis2_status_codes_t;
+ typedef enum axis2_error_codes axis2_error_codes_t;
/**
* @defgroup axis2_error error
@@ -567,55 +567,58 @@
* @{
*/
- /**
- * \brief Axis2 error ops struct
- *
- * Encapsulator struct for ops of axis2_error
- */
+ /**
+ * \brief Axis2 error ops struct
+ *
+ * Encapsulator struct for ops of axis2_error
+ */
typedef struct axis2_error_ops
{
- /**
- * deallocate memory of a error struct
- * @return axis2_status_t status code
- */
+ /**
+ * deallocate memory of a error struct
+ * @return axis2_status_t status code
+ */
axis2_status_t (AXIS2_CALL *free)(struct axis2_error *error);
- /**
- * get error message for the last error
- * @return error message for the last error. NULL on error.
- */
- const axis2_char_t *(AXIS2_CALL *
- get_message)(
- const struct axis2_error *error);
+ /**
+ * get error message for the last error
+ * @return error message for the last error. NULL on error.
+ */
+ const axis2_char_t *(AXIS2_CALL *
+ get_message)(
+ const struct axis2_error *error);
- /**
- * This fucntion is supposed to be overridden in an extended error structure.
- * For example in Sandesha error structure this fucntion is overridden so that
- * errors of axis2 range call the get_message function of error struct but
- * errors of sandesha2 range get the messages from an array of that struct.
- * @return error message for the extended struct.
- */
- const axis2_char_t *(AXIS2_CALL *
- get_extended_message)(
- const struct axis2_error *error);
+ /**
+ * This fucntion is supposed to be overridden in an extended error structure.
+ * For example in Sandesha error structure this fucntion is overridden so that
+ * errors of axis2 range call the get_message function of error struct but
+ * errors of sandesha2 range get the messages from an array of that struct.
+ * @return error message for the extended struct.
+ */
+ const axis2_char_t *(AXIS2_CALL *
+ get_extended_message)(
+ const struct axis2_error *error);
- axis2_status_t (AXIS2_CALL *set_error_number) (struct axis2_error *error
- , axis2_error_codes_t error_number);
+ axis2_status_t (AXIS2_CALL *set_error_number) (struct axis2_error *error
+ , axis2_error_codes_t error_number);
+
+ axis2_status_t (AXIS2_CALL *set_status_code) (struct axis2_error *error
+ , axis2_status_codes_t status_code);
- axis2_status_t (AXIS2_CALL *set_status_code) (struct axis2_error *error
- , axis2_status_codes_t status_code);
-
- axis2_status_t (AXIS2_CALL *get_status_code) (struct axis2_error *error);
+ axis2_status_t (AXIS2_CALL *get_status_code) (struct axis2_error *error);
+
+ axis2_status_t (AXIS2_CALL *set_error_message) (struct axis2_error *error
+ , axis2_char_t *message);
} axis2_error_ops_t;
- /**
- * \brief Axis2 Error struct
- *
- * Error holds the last errorno
- */
+ /**
+ * \brief Axis2 Error struct
+ *
+ * Error holds the last errorno
+ */
typedef struct axis2_error
{
/** error related ops */
@@ -623,17 +626,20 @@
axis2_allocator_t *allocator;
/** last error number */
int error_number;
-
int status_code;
+ axis2_char_t *message;
} axis2_error_t;
-AXIS2_EXTERN
-axis2_status_t AXIS2_CALL axis2_error_init();
+ AXIS2_EXTERN
+ axis2_status_t AXIS2_CALL axis2_error_init();
#define AXIS2_ERROR_FREE(error) ((error->ops)->free(error))
#define AXIS2_ERROR_GET_MESSAGE(error) \
((error)->ops->get_message(error))
+
+#define AXIS2_ERROR_SET_MESSAGE(error, message) \
+ ((error)->ops->set_error_message(error, message))
#define AXIS2_ERROR_SET_ERROR_NUMBER(error, error_number) \
((error)->ops->set_error_number(error, error_number))
Modified: webservices/axis2/trunk/c/util/src/error.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/error.c?view=diff&rev=485063&r1=485062&r2=485063
==============================================================================
--- webservices/axis2/trunk/c/util/src/error.c (original)
+++ webservices/axis2/trunk/c/util/src/error.c Sat Dec 9 13:36:02 2006
@@ -30,6 +30,9 @@
axis2_status_t AXIS2_CALL
axis2_error_impl_get_status_code(axis2_error_t *error);
+axis2_status_t AXIS2_CALL
+axis2_error_impl_set_error_message(axis2_error_t *error, axis2_char_t *message);
+
/* array to hold error messages */
const axis2_char_t* axis2_error_messages[AXIS2_ERROR_LAST];
@@ -519,6 +522,8 @@
(axis2_error_ops_t *) AXIS2_MALLOC(allocator,
sizeof(axis2_error_ops_t));
+ error->message = NULL;
+
if (!error->ops)
{
AXIS2_FREE(allocator, error);
@@ -531,17 +536,30 @@
error->ops->set_status_code = axis2_error_impl_set_status_code;
error->ops->get_status_code = axis2_error_impl_get_status_code;
error->ops->free = axis2_error_impl_free;
-
+ error->ops->set_error_message = axis2_error_impl_set_error_message;
return error;
}
const axis2_char_t * AXIS2_CALL
axis2_error_impl_get_message(const axis2_error_t *error)
{
- if (error && error->error_number >= AXIS2_ERROR_NONE && error->error_number < AXIS2_ERROR_LAST)
- return axis2_error_messages[error->error_number];
+ const axis2_char_t *message = NULL;
+ if (error)
+ {
+ if (error->error_number > AXIS2_ERROR_NONE && error->error_number < AXIS2_ERROR_LAST)
+ message = axis2_error_messages[error->error_number];
+ else
+ {
+ if (error->message)
+ message = error->message;
+ else if (error->error_number == AXIS2_ERROR_NONE)
+ message = axis2_error_messages[AXIS2_ERROR_NONE];
+ else
+ message = "Invalid Error Number";
+ }
+ }
- return "Invalid Error Number";
+ return message;
}
axis2_status_t AXIS2_CALL
@@ -562,4 +580,12 @@
axis2_error_impl_get_status_code(axis2_error_t *error)
{
return error->status_code;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_error_impl_set_error_message(axis2_error_t *error, axis2_char_t *message)
+{
+ if (message)
+ error->message = message;
+ return AXIS2_SUCCESS;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org