} catch (error) {
    if (error instanceof ConditionalCheckFailedException) {
      console.log("error", JSON.stringify(error, null, 2));

      let count = 0;
      if (error.Item) {
        count =
          unmarshall(error.Item as Record<string, AttributeValue>)
            .rateLimitCount || 0;
      }

      console.log("is at limit, returned:", count);

      if (throwOnLimit) {
        throw errorToThrow;
      }

      return true;
    }

    console.log("different error", error);

    throw error;
  }