Hi ,
I want to create reusable component for exception handling , have followed below posts and created shared flow and one proxy to achieve this but I am not able to get customised error message in browser, any help??
https://community.apigee.com/articles/39071/using-shared-flows-for-common-error-handling.html https://community.apigee.com/articles/23724/an-error-handling-pattern-for-apigee-proxies.html
Attaching shared flow and proxy flow.
Can anyone help me to troubleshoot issue?
Thanks
shared-flowconfiguration.zipproxy-configuration.zip
Solved! Go to Solution.
Hi @Ajay Tiwari
Thanks for sharing your proxy & shared flow!
"error" variable is a pre-defined variable which will be available only during error flow. I see in your assign message policy, you tried to assign values to standard variables like error.message, error.code etc.. which were not available by the time control reached to "Raise Fault" policy.
I suggest using custom variables in these cases, like below. It should work fine and it worked for me.
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-VerifyAPIKey"> <DisplayName>AM-VerifyAPIKey</DisplayName> <Properties/> <AssignVariable> <Name>flow.error.code</Name> <Value>400</Value> <Ref/> </AssignVariable> <AssignVariable> <Name>flow.error.message</Name> <Value>api key is invalid</Value> <Ref/> </AssignVariable> <AssignVariable> <Name>flow.error.info</Name> <Value>http://error.something.com</Value> <Ref/> </AssignVariable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
<RaiseFault async="false" continueOnError="false" enabled="true" name="RF-ErrorResponse"> <DisplayName>RF-ErrorResponse</DisplayName> <Properties/> <FaultResponse> <Set> <Headers/> <Payload contentType="application/json"> { "errorResponse": { "errorCode": "{flow.error.code}", "errorMessage": "{flow.error.message}", "errorInfo": "{flow.error.info}" } } </Payload> <StatusCode>{flow.error.code}</StatusCode> <ReasonPhrase>{flow.error.message}</ReasonPhrase> </Set> </FaultResponse> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </RaiseFault>
Please let me know how it went.
Regards
Vidheer
P.S: Please accept the answer, if it addressed your query 🙂
looks like attached "shared-flowconfiguration.zip" is same as "proxy-configuration.zip". Both are your proxy only. Can you please attach your shared flow instead?
Hi @Vidheer Gadikota attaching updated code please let me know if you need any other information
Hi @Ajay Tiwari
Thanks for sharing your proxy & shared flow!
"error" variable is a pre-defined variable which will be available only during error flow. I see in your assign message policy, you tried to assign values to standard variables like error.message, error.code etc.. which were not available by the time control reached to "Raise Fault" policy.
I suggest using custom variables in these cases, like below. It should work fine and it worked for me.
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-VerifyAPIKey"> <DisplayName>AM-VerifyAPIKey</DisplayName> <Properties/> <AssignVariable> <Name>flow.error.code</Name> <Value>400</Value> <Ref/> </AssignVariable> <AssignVariable> <Name>flow.error.message</Name> <Value>api key is invalid</Value> <Ref/> </AssignVariable> <AssignVariable> <Name>flow.error.info</Name> <Value>http://error.something.com</Value> <Ref/> </AssignVariable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage>
<RaiseFault async="false" continueOnError="false" enabled="true" name="RF-ErrorResponse"> <DisplayName>RF-ErrorResponse</DisplayName> <Properties/> <FaultResponse> <Set> <Headers/> <Payload contentType="application/json"> { "errorResponse": { "errorCode": "{flow.error.code}", "errorMessage": "{flow.error.message}", "errorInfo": "{flow.error.info}" } } </Payload> <StatusCode>{flow.error.code}</StatusCode> <ReasonPhrase>{flow.error.message}</ReasonPhrase> </Set> </FaultResponse> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </RaiseFault>
Please let me know how it went.
Regards
Vidheer
P.S: Please accept the answer, if it addressed your query 🙂
Thanks for your response solution really helped me.
Glad i was able to help!
same I am trying for multiple policies and this is not working have raised on diffrent thread.