Specific Custom Error Message from two Quota policies

We have a use case where we are using two Quota Policies , one with Quota per day and one with Quota per minute. Now we are using Assign Message policy (AM-QuotaLimitError) to throw the custom error message using fault rule like below

 <FaultRule name="quota-limit-error">
            <Step>
                <Name>AM-QuotaLimitError</Name>
            </Step>
            <Condition>(fault.name = "QuotaViolation")</Condition>
        </FaultRule>

Now we have two Quota Policies , so how to identify which Quota Policy is failing ?

As in both cases, we will have QuotaViolation Error, then how to provide the error message specific that Quota for Day is exceeded or Quota for Minute has exceeded ?

Please advise.

Thanks

0 2 370
2 REPLIES 2

Hi @GAURAV, You can use the flow variable "ratelimit.[policy_name].failed" in your fault rules to identify which of the two quota policies failed along with "fault.name".

Cheers!

Good call, @Mohammed Zuber. Also, @GAURAV, here's an alternative that makes sure the fault gets thrown when a policy specifically exceeds the quota. The fault handling best practices section of the docs also talks about this and includes an example.

http://docs.apigee.com/api-services/content/fault-handling#bestpracticesforfaulthandling

When a "QuotaViolation" occurs (from either policy), Edge then checks the inner conditions to see which fault message to fire:

<FaultRule name="over_quota">
<!-- This condition catches a QuotaViolation in *any* Quota policy -->
  <Condition>(fault.name = "QuotaViolation")</Condition>

  <Step>
    <Name>minute-quota-fault</Name>
    <Condition>(ratelimit.minute-quota-policy.exceed.count GreaterThan "0")</Condition>
  </Step>

  <Step>
    <Name>day-quota-fault</Name>
    <Condition>(ratelimit.day-quota-policy.exceed.count GreaterThan "0")</Condition>
  </Step>
</FaultRule>

See the variables you can use at http://docs.apigee.com/api-services/reference/quota-policy#variables.

For more info on building conditions, see http://docs.apigee.com/api-services/reference/conditions-reference.