What is the value flow variable fault.name when error is explicitly generated by Raisefault policy? I see it every time as RaiseFault.

 
1 6 731
6 REPLIES 6

Hi @AshwiniRai The fault.name variable contains the value of error code. You can then use fault.name variable in a <Condition> tag to handle the fault.

For e.g. when an app sends an invalid key, you want to send a custom message back. So in your fault handling you would put a condition like below and use a raise fault policy to send a custom error message -

 
<ProxyEndpoint name="default">
  ...
  <FaultRules>
    <FaultRule name="invalid_key_rule">
      <Step>
        <Name>RAISE_FAULT_POLICY_WITH_CUSTOM_MESSAGE</Name>
      </Step>
      <Condition>(fault.name = "InvalidApiKey")</Condition>
    </FaultRule>
  </FaultRules>
</ProxyEndpoint> 

Similarly if quota is violated, the Quota policy generates an error and the fault.name will be QuotaViolation. Referring to fault.name value, you could handle this event differently (do a service callout to notify some system or log a message etc.).

Thanks Sudheer, I know what you stated above. My scenario is little different here. I call a Raisefault policy in proxy endpoint preflow when some flow variable = some value. Now when the flow is in the Raisefault policy I refer {fault.name} flow variable and it always returned RaiseFault as its value.

Did you ever find another way around get the Raisefault fault.name?

Not applicable

Yes. It is set as RaiseFault. You can set reason phrase iin RaiseFault policy and then use AssignMessage policy to set the custom error message using this reason phrase or anything that you want to show to the user.

garysole
Participant II

I don't think the RaiseFault capability is working as it should. Just like Ashwini, I get the same problem - having a RaiseFault policy with a name -Xxx. It does not matter what the name of your fault policy is, fault.name variable value will always be "RaiseFault".

Having a DefaultRule to try and refer to the Fault Policy Name "Xxx" such as <Condition>(fault.name == "Xxx". This does not work.

You are better off just creating a JavaScript Policy to managing your error, or maybe setting the error code to some id value because setting a condition for error.status.code == 403 does work.

garysole
Participant II

I don't think the RaiseFault capability is working as it should. Just like Ashwini, I get the same problem - having a RaiseFault policy with a name -Xxx. It does not matter what the name of your fault policy is, fault.name variable value will always be "RaiseFault".

Having a DefaultRule to try and refer to the Fault Policy Name "Xxx" such as <Condition>(fault.name == "Xxx". This does not work.

You are better off just creating a JavaScript Policy to managing your error, or maybe setting the error code to some id value because setting a condition for error.status.code == 403 does work.