Hi,
No its wrong, we shouldn't response with 200 OK for  exceptions. IMO ideal
way as I think, to do this by keep the catalog of connector specific error
code and embedded in the error message and explain those _ _connector
specific error _ _  catalog in documentation more specifically, and
 returning a generic error with status code to client.

for error catalogs you could refer [1][2]
[1]http://www.twilio.com/docs/errors/reference
[2]
http://www.stormpath.com/blog/spring-mvc-rest-exception-handling-best-practices-part-1
e.g


{
    "status": 404,
   * "code": 40483,*
    "message": "Oops! It looks like that file does not exist.",
    "developerMessage": "File resource for path /uploads/foobar.txt
does not exist.  Please wait 10 minutes until the upload batch
completes before checking again.",
    "moreInfo": "http://www.mycompany.com/errors/40483";
}



On Tue, Feb 11, 2014 at 9:51 AM, Krishantha Dinesh <[email protected]>wrote:

> Hi Dushan/Dev
> I tried ur solution and its work. but i have other question. when it catch
> FAULT (500 error) on return message of client http code is 200 OK
> for example let say endpoint is fail the it catch that fault. but in
> client point of view http respond code of his response is 200
>
> other than 500 client getting correct http response code. the problem may
> be this is originate by ESB it self than come as response to ESB. btw is
> there any solution for this.
>
>
>
> On Sat, Feb 8, 2014 at 7:30 PM, Dushan Abeyruwan <[email protected]> wrote:
>
>> Hi Kirshantha,
>>   Handling fault has two flavors,
>>
>>    - Handle internal fault such as service EP not available and all the
>>    issues related .
>>    - Handle Service faults.
>>
>>
>>   Ideally when BE is SOAP and if it returns SOAP fault in order to handle
>> such queries we normally append FORCE_ERROR_ON_SOAP_FAULT property, this
>> works only of BE return Service faults and when such happen if we need to
>> divert such responses to the faultSequence that we have defined.
>>    On the other hand if that is RESTful BE,  we do not have a inbuilt
>> function  to determine whether its a fault at transport level, so the
>> workaround that we normally do is to use the Filter base on the HTTP_SC.
>>   If you look at [1] status codes represents 100 series and 200- series
>> regards as non faulty responses, and other than that we can determine them
>> as faults or defect, to overcome such station when deal with RESTful
>> services personally I am using filters i.e
>>
>> OutSequence ..etc , below logic just evaluates the response and if that
>> not falls between 200 series normally you can add your customize faulty
>> response logic ..
>>
>>  <filter source="$axis2:HTTP_SC" regex="^[^2][0-9][0-9]">
>>             <then>
>>                <log level="custom">
>>
>>    - can include payload
>>       - can setup HTTP_SC to axis2 context
>>       - can use <respond> mediator to reply client with error.
>>
>>                  ..............
>>                  ..............
>>
>>             </then>
>>          </filter>
>>
>>
>> [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>>
>>
>>
>>
>>
>> On Fri, Feb 7, 2014 at 7:54 PM, Krishantha Dinesh 
>> <[email protected]>wrote:
>>
>>> I have used following code to handle error on soap call
>>>
>>> proxy
>>> ==============
>>>
>>> <faultSequence>
>>>             <makefault version="soap11">
>>>                 <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope
>>> "
>>>                     value="get-property('FAULT_CODE')" />
>>>                 <reason expression="get-property('ERROR_CODE')" />
>>>                 <detail expression="get-property('ERROR_MESSAGE')" />
>>>             </makefault>
>>>             <send />
>>>         </faultSequence>
>>>
>>> Output
>>> ==============
>>> <soapenv:Envelope xmlns:soapenv="
>>> http://schemas.xmlsoap.org/soap/envelope/";>
>>>    <soapenv:Body>
>>>       <soapenv:Fault>
>>>          <faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope
>>> ">123456</faultcode>
>>>          <faultstring>abc</faultstring>
>>>          <detail>xyz</detail>
>>>       </soapenv:Fault>
>>>    </soapenv:Body>
>>> </soapenv:Envelope>
>>>
>>>
>>> I need to know what is the best approach to handle exception on REST
>>> calls.
>>>
>>> i tried to apply same way just for try but it only give ERROR_MESSAGE
>>> not another...
>>>
>>> my expectation is to deliver all exception to client (caller). eg:
>>> transport error due to unavailable endpoint.. etc
>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Dushan Abeyruwan | Associate Tech Lead
>>  Integration Technologies Team
>> PMC Member Apache Synpase
>> WSO2 Inc. http://wso2.com/
>> Blog:http://dushansview.blogspot.com/
>> Mobile:(0094)713942042
>>
>>
>


-- 
Dushan Abeyruwan | Associate Tech Lead
Integration Technologies Team
PMC Member Apache Synpase
WSO2 Inc. http://wso2.com/
Blog:http://dushansview.blogspot.com/
Mobile:(0094)713942042
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to