You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2007/10/05 09:55:10 UTC

svn commit: r582111 - in /webservices/axis2/trunk/c/util: include/axutil_error.h src/error.c

Author: samisa
Date: Fri Oct  5 00:55:09 2007
New Revision: 582111

URL: http://svn.apache.org/viewvc?rev=582111&view=rev
Log:
Fixed some formatting and did some improvement to the code

Modified:
    webservices/axis2/trunk/c/util/include/axutil_error.h
    webservices/axis2/trunk/c/util/src/error.c

Modified: webservices/axis2/trunk/c/util/include/axutil_error.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/include/axutil_error.h?rev=582111&r1=582110&r2=582111&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/include/axutil_error.h (original)
+++ webservices/axis2/trunk/c/util/include/axutil_error.h Fri Oct  5 00:55:09 2007
@@ -28,13 +28,12 @@
 #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 */
         AXIS2_CRITICAL_FAILURE = -1,
 
@@ -46,31 +45,33 @@
     };
 
     /**
-    * \brief Axis2 error codes
-    *
-    * Set of error codes for Axis2
-    */
+     * \brief Axis2 error codes
+     *
+     * Set of error codes for Axis2
+     */
     enum axutil_error_codes
     {
 
-        /** No error.
-            This must be the first error all the time and the assigned value of 0 
-            must not be changed as it is assumed in the error message array that 
-            the error list starts with a value of 0.
-            Further, none of the error codes in this enum should not be initialized 
-            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
+        /** 
+         * No error.
+         * This must be the first error all the time and the assigned value of 0 
+         * must not be changed as it is assumed in the error message array that 
+         * the error list starts with a value of 0.
+         * Further, none of the error codes in this enum should not be initialized 
+         * 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.
          */
         AXIS2_ERROR_NONE = 0,
 
+        /*
+         * Group - Common Errors
+         */
+        
         /** Out of memory */
         AXIS2_ERROR_NO_MEMORY,
 
-        /** NULL paramater was passed when a non NULL parameter was expected */
+        /** NULL parameter was passed when a non NULL parameter was expected */
         AXIS2_ERROR_INVALID_NULL_PARAM,
 
         /*
@@ -186,7 +187,7 @@
 
         /** Could not Map the MEP URI to a axis MEP constant value */
         AXIS2_ERROR_COULD_NOT_MAP_MEP_URI_TO_MEP_CONSTANT,
-        /* Invalid messge addition , operation context completed */
+        /* Invalid message addition , operation context completed */
         AXIS2_ERROR_INVALID_MESSAGE_ADDITION,
 
         /** Module description accessed has invalid state */
@@ -195,13 +196,13 @@
         /** Parameter container not set */
         AXIS2_ERROR_INVALID_STATE_PARAM_CONTAINER,
 
-        /** module has alredy engaged to the op op terminated !!! */
+        /** module has already engaged to the op op terminated !!! */
         AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_OP,
 
-        /** module has alredy been engaged on the service.Operation terminated !!! */
+        /** module has already been engaged on the service.Operation terminated !!! */
         AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC,
 
-        /** module has alredy been engaged on the service. Group Operation terminated !!! */
+        /** module has already been engaged on the service. Group Operation terminated !!! */
         AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC_GRP,
 
         /** Parameter locked, Cannot override */
@@ -244,17 +245,17 @@
         /** Last handler of phase already set */
         AXIS2_ERROR_PHASE_LAST_HANDLER_ALREADY_SET,
 
-        /**Two service can not have same name, a service with same name alredy
+        /**Two service can not have same name, a service with same name already
            exist in the system */
         AXIS2_ERROR_TWO_SVCS_CANNOT_HAVE_SAME_NAME,
         /*
-         * Group - core:phaseresolver
+         * Group - core:phase resolver
          */
         /* Invalid Module Ref */
         AXIS2_ERROR_INVALID_MODULE_REF,
         /* Invalid Phase */
         AXIS2_ERROR_INVALID_PHASE,
-        /* No Tranport Receiver is configured */
+        /* No Transport Receiver is configured */
         AXIS2_ERROR_NO_TRANSPORT_IN_CONFIGURED,
         /* No Transport Sender is configured */
         AXIS2_ERROR_NO_TRANSPORT_OUT_CONFIGURED,
@@ -276,7 +277,7 @@
         AXIS2_ERROR_OM_ELEMENT_INVALID_STATE,
         /* Om Elements do not match */
         AXIS2_ERROR_OM_ELEMENT_MISMATCH,
-        /* RPC style soap body don't have a child element */
+        /* RPC style SOAP body don't have a child element */
         AXIS2_ERROR_RPC_NEED_MATCHING_CHILD,
         /* Operation Description has unknown operation style  */
         AXIS2_ERROR_UNKNOWN_STYLE,
@@ -289,7 +290,7 @@
         /*
          * Group - core:transport:http
          */
-        /* Error occured in transport */
+        /* Error occurred in transport */
         AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR,
 
         /** A read attempt(HTTP) for the reply without sending the request */
@@ -297,7 +298,7 @@
 
         /** Invalid string passed as a http header */
         AXIS2_ERROR_INVALID_HEADER,
-        /* Invalid header start linei (request line or response line) */
+        /* Invalid header start line (request line or response line) */
         AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
         /* Transport protocol is unsupported by axis2 */
         AXIS2_ERROR_INVALID_TRANSPORT_PROTOCOL,
@@ -312,11 +313,11 @@
         AXIS2_ERROR_NULL_IN_STREAM_IN_MSG_CTX,
         /* OM output is NULL */
         AXIS2_ERROR_NULL_OM_OUTPUT,
-        /* Null soap envelope in msg_ctx */
+        /* Null SOAP envelope in msg_ctx */
         AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX,
-        /* NULL stream in the http chunked stream */
+        /* NULL stream in the http chucked stream */
         AXIS2_ERROR_NULL_STREAM_IN_CHUNKED_STREAM,
-        /* We got a NULL strem in the response body */
+        /* We got a NULL stream in the response body */
         AXIS2_ERROR_NULL_STREAM_IN_RESPONSE_BODY,
 
         /** URL NULL in http client */
@@ -334,15 +335,15 @@
 
         /** SOAP envelope or SOAP body NULL */
         AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL,
-        /* Error occured in SSL engine */
+        /* Error occurred in SSL engine */
         AXIS2_ERROR_SSL_ENGINE,
         /* Either axis2c cannot find certificates or the env variable is not set */
         AXIS2_ERROR_SSL_NO_CA_FILE,
         /* Error in writing the response in response writer */
         AXIS2_ERROR_WRITING_RESPONSE,
-        /* Required parameter is missing in url encoded request */
+        /* Required parameter is missing in URL encoded request */
         AXIS2_ERROR_REQD_PARAM_MISSING,
-        /* Unsuppoted schema type in REST */
+        /* Unsupported schema type in REST */
         AXIS2_ERROR_UNSUPPORTED_SCHEMA_TYPE,
         /* Service or operation not found */
         AXIS2_ERROR_SVC_OR_OP_NOT_FOUND,
@@ -377,7 +378,7 @@
         /** Array list index out of bounds */
         AXIS2_ERROR_INDEX_OUT_OF_BOUNDS,
 
-        /** Invalid IP or hostname */
+        /** Invalid IP or host name */
         AXIS2_ERROR_INVALID_ADDRESS,
 
         /** Trying to do operation on invalid file descriptor */
@@ -414,7 +415,7 @@
         /* 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,
@@ -451,10 +452,10 @@
         /** Builder done with pulling. Cannot pull any more */
         AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL,
 
-        /** Discard faile because the builder state is invalid */
+        /** Discard failed because the builder state is invalid */
         AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD,
 
-        /** Bulder's last node is NULL when it is not supposed to be NULL */
+        /** Builder's last node is NULL when it is not supposed to be NULL */
         AXIS2_ERROR_INVALID_BUILDER_STATE_LAST_NODE_NULL,
 
         /** Document root is NULL, when it is not supposed to be NULL */
@@ -470,7 +471,7 @@
         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
+        /** remove method has already been called once so cannot remove till
         next method is called valid for any om children iterator*/
         AXIS2_ERROR_ITERATOR_REMOVE_HAS_ALREADY_BEING_CALLED,
 
@@ -483,10 +484,10 @@
          * Group - xml:parser
          */
 
-        /** error occured creating xml stream reader */
+        /** error occurred creating xml stream reader */
         AXIS2_ERROR_CREATING_XML_STREAM_READER,
 
-        /** error occured creating xml stream writer */
+        /** error occurred creating xml stream writer */
         AXIS2_ERROR_CREATING_XML_STREAM_WRITER,
 
         /** error in writing attribute */
@@ -507,37 +508,37 @@
         /** error in writing default namespace */
         AXIS2_ERROR_WRITING_DEFAULT_NAMESPACE,
 
-        /** error in writing dtd */
+        /** error in writing DDT */
         AXIS2_ERROR_WRITING_DTD,
 
-        /** error occured in writing empty element */
+        /** error occurred in writing empty element */
         AXIS2_ERROR_WRITING_EMPTY_ELEMENT,
 
-        /** error occured in writing empty element with namespace */
+        /** error occurred in writing empty element with namespace */
         AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE,
 
         /** error in writing empty element with namespace prefix */
         AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE_PREFIX,
 
-        /** error occured in writing end document in xml writer */
+        /** error occurred in writing end document in xml writer */
         AXIS2_ERROR_WRITING_END_DOCUMENT,
 
-        /** error occured in writing end element in xml writer */
+        /** error occurred in writing end element in xml writer */
         AXIS2_ERROR_WRITING_END_ELEMENT,
 
         /** error in writing processing instruction */
         AXIS2_ERROR_WRITING_PROCESSING_INSTRUCTION,
 
-        /** error occured in writing start element in start document in xml writer */
+        /** error occurred in writing start element in start document in xml writer */
         AXIS2_ERROR_WRITING_START_DOCUMENT,
 
-        /** error occured in writing start element in xml writer */
+        /** error occurred in writing start element in xml writer */
         AXIS2_ERROR_WRITING_START_ELEMENT,
 
-        /** error occured in writing start element with namespace in xml writer*/
+        /** error occurred in writing start element with namespace in xml writer*/
         AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE,
 
-        /** error occured in writing start element with namespace prefix */
+        /** error occurred in writing start element with namespace prefix */
         AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE_PREFIX,
 
         /** error in writing cdata section */
@@ -547,71 +548,71 @@
         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 */
+        /** invalid SOAP namespace uri found */
         AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI,
 
         /** Invalid SOAP version */
         AXIS2_ERROR_INVALID_SOAP_VERSION,
         /* invalid value found in must understand attribute */
         AXIS2_ERROR_INVALID_VALUE_FOUND_IN_MUST_UNDERSTAND,
-        /*multiple code elements encountered in soap fault element */
+        /*multiple code elements encountered in SOAP fault element */
         AXIS2_ERROR_MULTIPLE_CODE_ELEMENTS_ENCOUNTERED,
-        /*multiple detail elements encountered in soap fault element */
+        /*multiple detail elements encountered in SOAP fault element */
         AXIS2_ERROR_MULTIPLE_DETAIL_ELEMENTS_ENCOUNTERED,
-        /*multiple node elements encountered in soap fault element */
+        /*multiple node elements encountered in SOAP fault element */
         AXIS2_ERROR_MULTIPLE_NODE_ELEMENTS_ENCOUNTERED,
-        /*multiple reason elements encountered in soap fault element */
+        /*multiple reason elements encountered in SOAP fault element */
         AXIS2_ERROR_MULTIPLE_REASON_ELEMENTS_ENCOUNTERED,
-        /*multiple role elements encounterd in soap fault element */
+        /*multiple role elements encountered in SOAP fault element */
         AXIS2_ERROR_MULTIPLE_ROLE_ELEMENTS_ENCOUNTERED,
-        /*multiple sub code values encountered in soap fault element */
+        /*multiple sub code values encountered in SOAP fault element */
         AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED,
-        /* multiple value elements encounered */
+        /* multiple value elements encountered */
         AXIS2_ERROR_MULTIPLE_VALUE_ENCOUNTERED_IN_CODE_ELEMENT,
-        /* must understatnd attribute should have values of true or false */
+        /* must understand attribute should have values of true or false */
         AXIS2_ERROR_MUST_UNDERSTAND_SHOULD_BE_1_0_TRUE_FALSE,
 
         /** om element is expected */
         AXIS2_ERROR_OM_ELEMENT_EXPECTED,
-        /* processing soap11 fault value element should have only
+        /* processing SOAP 1.1 fault value element should have only
            text as its children */
         AXIS2_ERROR_ONLY_CHARACTERS_ARE_ALLOWED_HERE,
 
         /** only one SOAP fault allowed in SOAP body */
         AXIS2_ERROR_ONLY_ONE_SOAP_FAULT_ALLOWED_IN_BODY,
-        /*soap11 fault actor element should not have child elements */
+        /*SOAP 1.1 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
+        /** SOAP builder found a child element other than header or body in envelope
         element */
         AXIS2_ERROR_SOAP_BUILDER_ENVELOPE_CAN_HAVE_ONLY_HEADER_AND_BODY,
 
-        /** soap builder encounterd body element first and header next */
+        /** SOAP builder encountered body element first and header next */
         AXIS2_ERROR_SOAP_BUILDER_HEADER_BODY_WRONG_ORDER,
 
-        /** soap builder multiple body elements encounterd */
+        /** SOAP builder multiple body elements encountered */
         AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_BODY_ELEMENTS_ENCOUNTERED,
 
-        /** soap builder encountered multiple headers */
+        /** SOAP builder encountered multiple headers */
         AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_HEADERS_ENCOUNTERED,
-        /*soap fault code element should a mandatory fault value element */
+        /*SOAP fault code element should a mandatory fault value element */
         AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE,
-        /*soap fault reason element should have a text */
+        /*SOAP fault reason element should have a text */
         AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT,
-        /*soap fault role element should have a text value */
+        /*SOAP fault role element should have a text value */
         AXIS2_ERROR_SOAP_FAULT_ROLE_ELEMENT_SHOULD_HAVE_A_TEXT,
-        /* soap fault value should be present before sub code element in soap fault code */
+        /* SOAP fault value should be present before sub code element in SOAP fault code */
         AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE,
 
-        /** soap message does not have an envelope element */
+        /** SOAP message does not have an envelope element */
         AXIS2_ERROR_SOAP_MESSAGE_DOES_NOT_CONTAIN_AN_ENVELOPE,
-        /*soap message first element must contain a localname */
+        /*SOAP message first element must contain a localname */
         AXIS2_ERROR_SOAP_MESSAGE_FIRST_ELEMENT_MUST_CONTAIN_LOCAL_NAME,
         /* this localname is not supported inside a reason element */
         AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_REASON_ELEMENT,
@@ -619,11 +620,11 @@
         AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_SUB_CODE_ELEMENT,
         /*this localname is not supported inside the code element */
         AXIS2_ERROR_THIS_LOCALNAME_NOT_SUPPORTED_INSIDE_THE_CODE_ELEMENT,
-        /*transport level identified soap version does not match with the soap version */
+        /*transport level identified SOAP version does not match with the SOAP version */
         AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP,
-        /*unsupported element in soap fault element */
+        /*unsupported element in SOAP fault element */
         AXIS2_ERROR_UNSUPPORTED_ELEMENT_IN_SOAP_FAULT_ELEMENT,
-        /*wrong element order encounterd */
+        /*wrong element order encountered */
         AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED,
         /*
          * Group - services
@@ -663,7 +664,7 @@
         AXIS2_ERROR_NEETHI_POLICY_CREATION_FAILED_FROM_ELEMENT,
         /*All Cannot be created from element */
         AXIS2_ERROR_NEETHI_ALL_CREATION_FAILED_FROM_ELEMENT,
-        /*Exactlyone Cannot be created element */
+        /*Exactly one Cannot be created element */
         AXIS2_ERROR_NEETHI_EXACTLYONE_CREATION_FAILED_FROM_ELEMENT,
         /*Reference Cannot be created from element */
         AXIS2_ERROR_NEETHI_REFERENCE_CREATION_FAILED_FROM_ELEMENT,
@@ -671,7 +672,7 @@
         AXIS2_ERROR_NEETHI_ASSERTION_CREATION_FAILED_FROM_ELEMENT,
         /*All creation failed */
         AXIS2_ERROR_NEETHI_ALL_CREATION_FAILED,
-        /*Exactlyone creation failed */
+        /*Exactly one creation failed */
         AXIS2_ERROR_NEETHI_EXACTLYONE_CREATION_FAILED,
         /*Policy Creation failed */
         AXIS2_ERROR_NEETHI_POLICY_CREATION_FAILED,
@@ -687,37 +688,22 @@
         AXIS2_ERROR_NEETHI_URI_NOT_SPECIFIED,
         /*Policy NULL for the given uri */
         AXIS2_ERROR_NEETHI_NO_ENTRY_FOR_THE_GIVEN_URI,
-        /*Exactlyone not found in Normalized policy */
+        /*Exactly one not found in Normalized policy */
         AXIS2_ERROR_NEETHI_EXACTLYONE_NOT_FOUND_IN_NORMALIZED_POLICY,
-        /*Exactlyone is Empty */
+        /*Exactly one is Empty */
         AXIS2_ERROR_NEETHI_EXACTLYONE_IS_EMPTY,
-        /*Exactlyone not found while getting cross product */
+        /*Exactly one not found while getting cross product */
         AXIS2_ERROR_NEETHI_ALL_NOT_FOUND_WHILE_GETTING_CROSS_PRODUCT,
 
-        /** The following has to be the last error value all the time.
-            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.
-        */
+        /** 
+         * The following has to be the last error value all the time.
+         * 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 messages array.
+         */
         AXIS2_ERROR_LAST
     };
 
-    /**
-     * \brief Array to hold error messages
-     * Array to hold error messages. Note that array has capacity for 
-     * additional error messages. These are reserved for modules.
-     * In writing a module following steps must be followed in extending axis2c
-     * errors
-     * 1. Declare the start of error messages for the new module.
-          For example in sandesha2 module we have
-          #define SANDESHA2_ERROR_CODES_START (AXIS2_ERROR_LAST + 1000)
-          Above line indicates that the new modules error messages start from 
-          1000 messages after the axis2 last error message.
-       2. New module can use up to 1000 messages for its errors.
-       3. In axis2c documentation an entry about new modules error range must
-          be inserted so that another new module can know about the already
-          occupied spaces. 
-     */
     struct axutil_error;
     typedef enum axis2_status_codes axis2_status_codes_t;
     typedef enum axutil_error_codes axutil_error_codes_t;
@@ -729,74 +715,118 @@
      */
 
     /**
-    * deallocate memory of a error struct
-    * @return axis2_status_t status code
-    */
-    AXIS2_EXTERN void AXIS2_CALL
-    axutil_error_free(
-        struct axutil_error *error);
+     * Axutil error struct.
+     * Error holds the last error number, the status code as well as the 
+     * last error message.
+     */
+    typedef struct axutil_error
+    {
+        /** 
+         * Memory allocator associated with the error struct. 
+         * It is this allocator that would be used to allocate memory 
+         * for the error struct instance in create method.
+         */
+        axutil_allocator_t *allocator;
+
+        /** Last error number. */
+        int error_number;
+        /** Last status code. */
+        int status_code;
+        /** 
+         * Error message. This could be set to a custom message to be 
+         * returned, instead of standard errors set in the error messages 
+         * array by the axutil_error_init function call.
+         */
+        axis2_char_t *message;
+    }
+    axutil_error_t;
 
     /**
-    * get error message for the last error
-    * @return error message for the last error. NULL on error.
-    */
+     * Gets the error message corresponding to the last error occurred.
+     * @param error pointer to error struct 
+     * @return string representing the error message for the last error occurred
+     */
     AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
     axutil_error_get_message(
         const struct axutil_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.
-    */
-    AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
-
+     * This function is supposed to be overridden in an extended error structure.
+     * For example in Sandesha error structure this function 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.
+     * @deprecated this function is not in use, so should be removed.
+     */
+    /*AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
     axutil_error_get_extended_message(
-        const struct axutil_error *error);
+        const struct axutil_error *error);*/
 
+    /**
+     * Sets the error number.
+     * @param error pointer to error struct 
+     * @param error_number error number to be set
+     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+     */
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
     axutil_error_set_error_number(
         struct axutil_error *error,
         axutil_error_codes_t error_number);
 
+    /**
+     * Sets the status code.
+     * @param error pointer to error struct 
+     * @param status_code status code to be set
+     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+     */
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
     axutil_error_set_status_code(
         struct axutil_error *error,
         axis2_status_codes_t status_code);
 
+    /**
+     * Gets the status code.
+     * @param error pointer to error struct 
+     * @return last status code set on error struct
+     */
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
     axutil_error_get_status_code(
         struct axutil_error *error);
 
+    /**
+     * Sets error message to the given value.
+     * @param error pointer to error struct 
+     * @param message error message to be set
+     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+     */
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
     axutil_error_set_error_message(
         struct axutil_error *error,
-        axis2_char_t * message);
+        axis2_char_t *message);
 
     /**
-    * \brief Axis2 Error struct
-    *
-    * Error holds the last errorno
-    */
-    typedef struct axutil_error
-    {
-
-        /** error related ops */
-        axutil_allocator_t *allocator;
-
-        /** last error number */
-        int error_number;
-        int status_code;
-        axis2_char_t *message;
-    }
-    axutil_error_t;
-
+     * Initializes the axutil_error_messages array. This array holds the 
+     * error messages that corresponds to the error codes. This function
+     * must be call before using the error struct instance.
+     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+     */
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axutil_error_init(
-    );
+    axutil_error_init();
+
+    /**
+     * De-allocates an error struct instance.
+     * @param error pointer to error struct instance to be freed.
+     * @return void
+     */
+    AXIS2_EXTERN void AXIS2_CALL
+    axutil_error_free(
+        struct axutil_error *error);
 
+/** 
+ * @deprecated The following macros are no longer useful as we can use the 
+ * function calls directly. Hence these macros should be removed 
+ */
+  
 #define AXIS2_ERROR_FREE(error) axutil_error_free(error)
 
 #define AXIS2_ERROR_GET_MESSAGE(error) \

Modified: webservices/axis2/trunk/c/util/src/error.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/util/src/error.c?rev=582111&r1=582110&r2=582111&view=diff
==============================================================================
--- webservices/axis2/trunk/c/util/src/error.c (original)
+++ webservices/axis2/trunk/c/util/src/error.c Fri Oct  5 00:55:09 2007
@@ -17,17 +17,42 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include "axutil_error_default.h"
 
-AXIS2_EXPORT const axis2_char_t *axutil_error_messages[AXIS2_ERROR_LAST +
-                                                       10000];
+#define AXIS2_ERROR_ADDITIONAL_BUFFER_SIZE 10000
+
+#define AXIS2_ERROR_MESSAGE_ARRAY_SIZE \
+    (AXIS2_ERROR_LAST + AXIS2_ERROR_ADDITIONAL_BUFFER_SIZE)
+
+/**
+ * Array to hold error messages corresponding to the pre-defined error codes.
+ * Note that array has capacity for additional error messages. These are 
+ * reserved for modules.
+ *
+ * TODO: We have to review and change the following definition and also 
+ * need to come up with a reserve strategy for module error code blocks.
+ *
+ * In writing a module following steps must be followed in extending Axis2/C
+ * errors
+ * 1. Declare the start of error messages for the new module.
+      For example in sandesha2 module we have
+      #define SANDESHA2_ERROR_CODES_START (AXIS2_ERROR_LAST + 1000)
+      Above line indicates that the new modules error messages start from 
+      1000 messages after the axis2 last error message.
+   2. New module can use up to 1000 messages for its errors.
+   3. In axis2c documentation an entry about new modules error range must
+      be inserted so that another new module can know about the already
+      occupied spaces. 
+ */
+AXIS2_EXPORT const axis2_char_t *axutil_error_messages[
+        AXIS2_ERROR_MESSAGE_ARRAY_SIZE];
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_error_init(
-    )
+axutil_error_init()
 {
     int i = 0;
-    for (i = 0; i < AXIS2_ERROR_LAST; i++)
+    for (i = 0; i < AXIS2_ERROR_MESSAGE_ARRAY_SIZE ; i++)
     {
         axutil_error_messages[i] = "Unknown Error :(";
     }
@@ -36,7 +61,7 @@
     axutil_error_messages[AXIS2_ERROR_NONE] = "No Error";
     axutil_error_messages[AXIS2_ERROR_NO_MEMORY] = "Out of memory";
     axutil_error_messages[AXIS2_ERROR_INVALID_NULL_PARAM] =
-        "NULL paramater was passed when a non NULL parameter was expected";
+        "NULL parameter was passed when a non NULL parameter was expected";
     /* core:addr */
 
     /* core:clientapi */
@@ -120,17 +145,17 @@
     axutil_error_messages[AXIS2_ERROR_COULD_NOT_MAP_MEP_URI_TO_MEP_CONSTANT] =
         "Could not Map the MEP URI to a axis MEP constant value";
     axutil_error_messages[AXIS2_ERROR_INVALID_MESSAGE_ADDITION] =
-        "Invalid messge addition operation context completed";
+        "Invalid message addition operation context completed";
     axutil_error_messages[AXIS2_ERROR_INVALID_STATE_MODULE_DESC] =
         "Module description accessed has invalid state";
     axutil_error_messages[AXIS2_ERROR_INVALID_STATE_PARAM_CONTAINER] =
         "Parameter container not set";
     axutil_error_messages[AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_OP] =
-        "module has alredy engaged to the op op terminated !!!";
+        "module has already engaged to the op op terminated !!!";
     axutil_error_messages[AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC] =
-        "module has alredy been engaged on the service.Operation terminated !!!";
+        "module has already been engaged on the service.Operation terminated !!!";
     axutil_error_messages[AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC_GRP] =
-        "module has alredy been engaged on the service. Group Operation terminated !!!";
+        "module has already been engaged on the service. Group Operation terminated !!!";
     axutil_error_messages[AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE] =
         "Parameter locked, Cannot override";
     axutil_error_messages[AXIS2_ERROR_EMPTY_SCHEMA_LIST] =
@@ -158,7 +183,7 @@
     axutil_error_messages[AXIS2_ERROR_PHASE_LAST_HANDLER_ALREADY_SET] =
         "Last handler of phase already set";
     axutil_error_messages[AXIS2_ERROR_TWO_SVCS_CANNOT_HAVE_SAME_NAME] =
-        "Two service can not have same name, a service with same name alredy";
+        "Two service can not have same name, a service with same name already";
     /* core:phaseresolver */
     axutil_error_messages[AXIS2_ERROR_INVALID_MODULE_REF] =
         "Invalid Module Ref";
@@ -188,7 +213,7 @@
 
     /* core:transport:http */
     axutil_error_messages[AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR] =
-        "Error occured in transport";
+        "Error occurred in transport";
     axutil_error_messages[AXIS2_ERROR_HTTP_REQUEST_NOT_SENT] =
         "A read attempt(HTTP) for the reply without sending the request";
     axutil_error_messages[AXIS2_ERROR_INVALID_HEADER] =
@@ -209,7 +234,7 @@
     axutil_error_messages[AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX] =
         "Null soap envelope in msg_ctx";
     axutil_error_messages[AXIS2_ERROR_NULL_STREAM_IN_CHUNKED_STREAM] =
-        "NULL stream in the http chunked stream";
+        "NULL stream in the http chucked stream";
     axutil_error_messages[AXIS2_ERROR_NULL_STREAM_IN_RESPONSE_BODY] =
         "We got a NULL stream in the response body";
     axutil_error_messages[AXIS2_ERROR_NULL_URL] = "URL NULL in http client";
@@ -222,15 +247,15 @@
     axutil_error_messages[AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL] =
         "SOAP envelope or SOAP body NULL";
     axutil_error_messages[AXIS2_ERROR_SSL_ENGINE] =
-        "Error occured in SSL engine";
+        "Error occurred in SSL engine";
     axutil_error_messages[AXIS2_ERROR_SSL_NO_CA_FILE] =
         "Either axis2c cannot find certificates or the env variable is not set";
     axutil_error_messages[AXIS2_ERROR_WRITING_RESPONSE] =
         "Error in writing the response in response writer";
     axutil_error_messages[AXIS2_ERROR_REQD_PARAM_MISSING] =
-        "Required parameter is missing in url encoded request";
+        "Required parameter is missing in URL encoded request";
     axutil_error_messages[AXIS2_ERROR_UNSUPPORTED_SCHEMA_TYPE] =
-        " Unsuppoted schema type in REST";
+        " Unsupported schema type in REST";
     axutil_error_messages[AXIS2_ERROR_SVC_OR_OP_NOT_FOUND] =
         "Service or operation not found";
     /* mod_addr */
@@ -241,7 +266,7 @@
     axutil_error_messages[AXIS2_ERROR_COULD_NOT_OPEN_FILE] =
         "Could not open the file";
     axutil_error_messages[AXIS2_ERROR_DLL_CREATE_FAILED] =
-        "Failed in creating DLL";
+        "Failed in creating DALL";
     axutil_error_messages[AXIS2_ERROR_DLL_LOADING_FAILED] =
         "DLL loading failed";
     axutil_error_messages[AXIS2_ERROR_ENVIRONMENT_IS_NULL] =
@@ -249,7 +274,7 @@
     axutil_error_messages[AXIS2_ERROR_FILE_NAME_NOT_SET] =
         "Axis2 File does not have a file name";
     axutil_error_messages[AXIS2_ERROR_INVALID_STATE_DLL_DESC] =
-        "dll description has invalid state of not having valid dll create function, \
+        "DLL description has invalid state of not having valid DLL create function, \
         of valid delete function or valid dll_handler";
     axutil_error_messages[AXIS2_ERROR_HANDLER_CREATION_FAILED] =
         "Failed in creating Handler";
@@ -312,9 +337,9 @@
     axutil_error_messages[AXIS2_ERROR_BUILDER_DONE_CANNOT_PULL] =
         "Builder done with pulling. Cannot pull any more";
     axutil_error_messages[AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD] =
-        "Discard faile because the builder state is invalid";
+        "Discard failed because the builder state is invalid";
     axutil_error_messages[AXIS2_ERROR_INVALID_BUILDER_STATE_LAST_NODE_NULL] =
-        "Bulder's last node is NULL when it is not supposed to be NULL";
+        "Builder's last node is NULL when it is not supposed to be NULL";
     axutil_error_messages[AXIS2_ERROR_INVALID_DOCUMENT_STATE_ROOT_NULL] =
         "Document root is NULL] =  when it is not supposed to be NULL";
     axutil_error_messages
@@ -334,9 +359,9 @@
         "axiom_xml_reader returned NULL value";
     /* xml:parser */
     axutil_error_messages[AXIS2_ERROR_CREATING_XML_STREAM_READER] =
-        "error occured creating xml stream reader";
+        "error occurred creating xml stream reader";
     axutil_error_messages[AXIS2_ERROR_CREATING_XML_STREAM_WRITER] =
-        "error occured creating xml stream writer";
+        "error occurred creating xml stream writer";
     axutil_error_messages[AXIS2_ERROR_WRITING_ATTRIBUTE] =
         "error in writing attribute";
     axutil_error_messages[AXIS2_ERROR_WRITING_ATTRIBUTE_WITH_NAMESPACE] =
@@ -349,29 +374,29 @@
         "error in writing data source";
     axutil_error_messages[AXIS2_ERROR_WRITING_DEFAULT_NAMESPACE] =
         "error in writing default namespace";
-    axutil_error_messages[AXIS2_ERROR_WRITING_DTD] = "error in writing dtd";
+    axutil_error_messages[AXIS2_ERROR_WRITING_DTD] = "error in writing DDT";
     axutil_error_messages[AXIS2_ERROR_WRITING_EMPTY_ELEMENT] =
-        "error occured in writing empty element";
+        "error occurred in writing empty element";
     axutil_error_messages[AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE] =
-        "error occured in writing empty element with namespace";
+        "error occurred in writing empty element with namespace";
     axutil_error_messages
         [AXIS2_ERROR_WRITING_EMPTY_ELEMENT_WITH_NAMESPACE_PREFIX] =
         "error in writing empty element with namespace prefix";
     axutil_error_messages[AXIS2_ERROR_WRITING_END_DOCUMENT] =
-        "error occured in writing end document in xml writer";
+        "error occurred in writing end document in xml writer";
     axutil_error_messages[AXIS2_ERROR_WRITING_END_ELEMENT] =
-        "error occured in writing end element in xml writer";
+        "error occurred in writing end element in xml writer";
     axutil_error_messages[AXIS2_ERROR_WRITING_PROCESSING_INSTRUCTION] =
         "error in writing processing instruction";
     axutil_error_messages[AXIS2_ERROR_WRITING_START_DOCUMENT] =
-        "error occured in writing start element in start document in xml writer";
+        "error occurred in writing start element in start document in xml writer";
     axutil_error_messages[AXIS2_ERROR_WRITING_START_ELEMENT] =
-        "error occured in writing start element in xml writer";
+        "error occurred in writing start element in xml writer";
     axutil_error_messages[AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE] =
-        "error occured in writing start element with namespace in xml writer";
+        "error occurred in writing start element with namespace in xml writer";
     axutil_error_messages
         [AXIS2_ERROR_WRITING_START_ELEMENT_WITH_NAMESPACE_PREFIX] =
-        "error occured in writing start element with namespace prefix";
+        "error occurred in writing start element with namespace prefix";
     axutil_error_messages[AXIS2_ERROR_WRITING_CDATA] =
         "error in writing cdata section";
     axutil_error_messages[AXIS2_ERROR_XML_PARSER_INVALID_MEM_TYPE] =
@@ -397,12 +422,12 @@
     axutil_error_messages[AXIS2_ERROR_MULTIPLE_ROLE_ELEMENTS_ENCOUNTERED] =
         "multiple fault role elements encountered in soap fault ";
     axutil_error_messages[AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED] =
-        "multiple fault subcode value elements encountered";
+        "multiple fault sub-code value elements encountered";
     axutil_error_messages
         [AXIS2_ERROR_MULTIPLE_VALUE_ENCOUNTERED_IN_CODE_ELEMENT] =
-        "multiple fault value elements encounterd";
+        "multiple fault value elements encountered";
     axutil_error_messages[AXIS2_ERROR_MUST_UNDERSTAND_SHOULD_BE_1_0_TRUE_FALSE]
-        = "must understatnd attribute should have values of true or false";
+        = "must understand attribute should have values of true or false";
     axutil_error_messages[AXIS2_ERROR_OM_ELEMENT_EXPECTED] =
         "om element is expected";
     axutil_error_messages[AXIS2_ERROR_ONLY_CHARACTERS_ARE_ALLOWED_HERE] =
@@ -418,10 +443,10 @@
         "soap builder found a child element other than header or body in envelope"
         "element";
     axutil_error_messages[AXIS2_ERROR_SOAP_BUILDER_HEADER_BODY_WRONG_ORDER] =
-        "soap builder encounterd body element first and header next";
+        "soap builder encountered body element first and header next";
     axutil_error_messages
         [AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_BODY_ELEMENTS_ENCOUNTERED] =
-        "soap builder multiple body elements encounterd";
+        "soap builder multiple body elements encountered";
     axutil_error_messages[AXIS2_ERROR_SOAP_BUILDER_MULTIPLE_HEADERS_ENCOUNTERED]
         = "soap builder encountered multiple headers";
     axutil_error_messages[AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE] =
@@ -434,18 +459,18 @@
         "soap fault role element should have a text value";
     axutil_error_messages
         [AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE] =
-        "soap fault value should be present before subcode element in soap fault code";
+        "soap fault value should be present before sub-code element in soap fault code";
     axutil_error_messages[AXIS2_ERROR_SOAP_MESSAGE_DOES_NOT_CONTAIN_AN_ENVELOPE]
         = "soap message does not contain a soap envelope element";
     axutil_error_messages
         [AXIS2_ERROR_SOAP_MESSAGE_FIRST_ELEMENT_MUST_CONTAIN_LOCAL_NAME] =
-        "soap messgae first element should have a localname";
+        "soap message first element should have a localname";
     axutil_error_messages
         [AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_REASON_ELEMENT]
         = "localname not supported inside a reason element";
     axutil_error_messages
         [AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_SUB_CODE_ELEMENT]
-        = "localname not supported inside the subcode element";
+        = "localname not supported inside the sub-code element";
     axutil_error_messages
         [AXIS2_ERROR_THIS_LOCALNAME_NOT_SUPPORTED_INSIDE_THE_CODE_ELEMENT] =
         "localname not supported inside the code element";
@@ -489,7 +514,7 @@
         "All creation failed from element";
     axutil_error_messages
         [AXIS2_ERROR_NEETHI_EXACTLYONE_CREATION_FAILED_FROM_ELEMENT] =
-        "Exactlyone creation failed from element";
+        "Exactly one creation failed from element";
     axutil_error_messages
         [AXIS2_ERROR_NEETHI_REFERENCE_CREATION_FAILED_FROM_ELEMENT] =
         "Reference creation failed from element";
@@ -499,7 +524,7 @@
     axutil_error_messages[AXIS2_ERROR_NEETHI_ALL_CREATION_FAILED] =
         "All Creation failed";
     axutil_error_messages[AXIS2_ERROR_NEETHI_EXACTLYONE_CREATION_FAILED] =
-        "Exactlyone Creation failed";
+        "Exactly one Creation failed";
     axutil_error_messages[AXIS2_ERROR_NEETHI_POLICY_CREATION_FAILED] =
         "Policy Creation failed";
     axutil_error_messages[AXIS2_ERROR_NEETHI_NORMALIZATION_FAILED] =
@@ -516,9 +541,9 @@
         "No entry for the given Uri";
     axutil_error_messages
         [AXIS2_ERROR_NEETHI_EXACTLYONE_NOT_FOUND_IN_NORMALIZED_POLICY] =
-        "Exactlyone not found in normalized_policy";
+        "Exactly one not found in normalized_policy";
     axutil_error_messages[AXIS2_ERROR_NEETHI_EXACTLYONE_IS_EMPTY] =
-        "Exactlyone is Empty";
+        "Exactly one is Empty";
     axutil_error_messages
         [AXIS2_ERROR_NEETHI_ALL_NOT_FOUND_WHILE_GETTING_CROSS_PRODUCT] =
         "All not found while getting cross product";
@@ -526,17 +551,6 @@
     return AXIS2_SUCCESS;
 }
 
-AXIS2_EXTERN void AXIS2_CALL
-axutil_error_free(
-    axutil_error_t * error)
-{
-    if (error)
-    {
-        AXIS2_FREE(error->allocator, error);
-    }
-    return;
-}
-
 AXIS2_EXTERN axutil_error_t *AXIS2_CALL
 axutil_error_create(
     axutil_allocator_t * allocator)
@@ -546,14 +560,13 @@
         return NULL;
 
     error = (axutil_error_t *) AXIS2_MALLOC(allocator, sizeof(axutil_error_t));
+    memset(error, 0,  sizeof(axutil_error_t));
 
     if (!error)
         return NULL;
 
     error->allocator = allocator;
 
-    error->message = NULL;
-
     return error;
 }
 
@@ -565,7 +578,8 @@
     if (error)
     {
         if (error->error_number > AXIS2_ERROR_NONE &&
-            error->error_number < AXIS2_ERROR_LAST)
+            error->error_number < AXIS2_ERROR_LAST) /* TODO; This needs to be 
+            fixed to include module defined and user defined errors */
             message = axutil_error_messages[error->error_number];
         else
         {
@@ -587,6 +601,8 @@
     axutil_error_t * error,
     axutil_error_codes_t error_number)
 {
+    if (!error)
+        return AXIS2_FAILURE;
     error->error_number = error_number;
     return AXIS2_SUCCESS;
 }
@@ -596,6 +612,8 @@
     axutil_error_t * error,
     axis2_status_codes_t status_code)
 {
+    if (!error)
+        return AXIS2_FAILURE;
     error->status_code = status_code;
     return AXIS2_SUCCESS;
 }
@@ -604,7 +622,10 @@
 axutil_error_get_status_code(
     axutil_error_t * error)
 {
-    return error->status_code;
+    if (error)
+        return error->status_code;
+    else
+        return AXIS2_CRITICAL_FAILURE;
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -612,7 +633,24 @@
     axutil_error_t * error,
     axis2_char_t * message)
 {
-    if (message)
+    if (message && error)
+    {
         error->message = message;
-    return AXIS2_SUCCESS;
+        return AXIS2_SUCCESS;
+    }
+    
+    return AXIS2_FAILURE;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axutil_error_free(
+    axutil_error_t * error)
+{
+    if (error)
+    {
+        AXIS2_FREE(error->allocator, error);
+    }
+    return;
 }
+
+



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