Error reference

Use this page when you need to map expected failures from SDK calls or HTTP responses.

SDK errors

TaxKit.safe.calculate returns a tagged success or failure value.

ResultMeaning
TaxKitSuccessThe calculation returned a descriptor-decoded report.
TaxKitFailureThe calculation failed with TaxKitCalculationError.

TaxKitCalculationError.error can contain a CalculatorServiceError, a schema decode error from descriptor output decoding or an unexpected defect wrapper. It can also contain TaxKitClientDisposedError when the client has already closed. A safe disposal failure is TaxKitClientDisposeError; the Plain SDK explains the client lifetime.

CalculatorServiceError

The calculator service uses CalculatorServiceError for expected failures.

ErrorHandling guidance
CalculatorInputDecodeErrorShow issue paths and optional descriptor help.
UnsupportedCalculatorErrorTreat the calculator id as an integration error.
UnsupportedCalculatorContextErrorAsk the caller to choose a supported jurisdiction and tax year.
CalculationErrorThe rule calculation could not produce a supported result.
CalculatorCapacityExceededThe server has no free calculation place. Retry manually after the current work finishes.
CalculatorOperationTimedOutThe operation reached its time limit. Retry manually.
CalculatorRateLimitedThe native per-client calculation limit was reached. Wait for Retry-After and retry manually.
CalculatorAdmissionUnavailableThe native request identity or rate limiter is unavailable. Retry manually.

HTTP errors

The HTTP API wraps expected calculator service failures in CalculatorApiErrorEnvelope. The envelope is owned by @taxkit/api-http because it describes transport status encoding.

json
{
  "error": {
    "_tag": "CalculatorInputDecodeError",
    "calculatorId": "au.pay.take-home",
    "issues": [
      {
        "_tag": "CalculatorInputIssue",
        "path": ["grossPay"],
        "message": "Expected GrossPay"
      }
    ],
    "message": "Invalid facts for au.pay.take-home"
  }
}

Use ?help=errors when you want descriptor-backed field help for invalid facts.

Error flow

ts
Production: expected calculator failure

Caller
  -> TaxKit.safe.calculate or HTTP calculate
    -> PublicCalculatorService.calculate
      -> CalculatorServiceError
    -> TaxKitFailure or CalculatorApiErrorEnvelope

Owning sources

Used by

In checked TypeScript, CalculationError.cause uses nested Options and defaults to a missing field. Its encoded error keeps the existing missing, undefined, null and diagnostic-value forms. The current rules omit this field. Existing diagnostic values are not safe to send to logs, traces or product events.