Skip to main content

index/variables/ERROR_CODES.md

const ERROR_CODES: object

Standard error codes for ValidationError

Use these constants instead of string literals for:

  • IDE autocomplete support
  • Typo prevention
  • Consistent error handling across the SDK

Type Declaration​

NameTypeDescription
ARRAY_TOO_LARGE"ARRAY_TOO_LARGE"Array exceeds maximum length
EMPTY_ARRAY"EMPTY_ARRAY"Array is empty when it shouldn't be
INVALID_DATA"INVALID_DATA"Position data is malformed or incomplete
INVALID_FEE_TIER"INVALID_FEE_TIER"Fee tier is not valid (500, 3000, 10000)
INVALID_FORMAT"INVALID_FORMAT"Field doesn't match required pattern (regex)
INVALID_PARAMETERS"INVALID_PARAMETERS"HTTP request parameters are invalid
INVALID_RANGE"INVALID_RANGE"Price range is invalid (min >= max)
INVALID_TICK_SPACING"INVALID_TICK_SPACING"Tick spacing doesn't match fee tier requirements
INVALID_TYPE"INVALID_TYPE"Field has wrong type (string expected, got number, etc.)
INVALID_VALUE"INVALID_VALUE"Field value is outside acceptable range or set
NOT_FOUND"NOT_FOUND"Resource (position, pool, etc.) not found
REQUIRED"REQUIRED"Field is null, undefined, or missing
TOO_LARGE"TOO_LARGE"Numeric value exceeds maximum
TOO_LONG"TOO_LONG"Field length exceeds maximum
TOO_SHORT"TOO_SHORT"Field length is below minimum
TOO_SMALL"TOO_SMALL"Numeric value is below minimum
ZERO_VALUE"ZERO_VALUE"Value is zero when non-zero expected

Example​

import { ValidationError, ERROR_CODES } from '../utils/errors';

throw new ValidationError('tokenName is required', 'tokenName', ERROR_CODES.REQUIRED);

Since​

6.3.0