<commit_before>package smartling

import (
	"bytes"
	"io"
	"log"
	"net"
	"strings"
	"time"

	smartlingNew "github.com/Smartling/api-sdk-go"
)

func isResourceLockedError(err error) bool {
	if err != nil {
		if sErr, ok := err.(SmartlingResponse); ok {
			return sErr.IsResourceLockedError()
		}
	}
	return false
}

func isNetworkErrClosing(err error) bool {
	if err != nil {
		return strings.Contains(err.Error(), "use of closed network connection")
	}
	return false
}

func isTimeoutError(err error) bool {
	if err != nil {
		if netErr, ok := err.(net.Error); ok {
			return netErr.Timeout()
		}
	}
	return false
}

func isRetryableError(err error) bool {
	return isResourceLockedError(err) || isNetworkErrClosing(err) || isTimeoutError(err)
}

func streamToByte(stream io.Reader) []byte {
	buf := new(bytes.Buffer)
	buf.ReadFrom(stream)
	return buf.Bytes()
}<commit_msg>Use sdk for API errors<commit_after>package smartling

import (
	"bytes"
	"io"
	"log"
	"net"
	"strings"
	"time"

	smartlingNew "github.com/Smartling/api-sdk-go"
)

func isResourceLockedError(err error) bool {
	if err != nil {
		if sErr, ok := err.(smartlingNew.APIError); ok {
			return sErr.Code == "RESOURCE_LOCKED"
		}
	}
	return false
}

func isNetworkErrClosing(err error) bool {
	if err != nil {
		return strings.Contains(err.Error(), "use of closed network connection")
	}
	return false
}

func isTimeoutError(err error) bool {
	if err != nil {
		if netErr, ok := err.(net.Error); ok {
			return netErr.Timeout()
		}
	}
	return false
}

func isRetryableError(err error) bool {
	return isResourceLockedError(err) || isNetworkErrClosing(err) || isTimeoutError(err)
}

func streamToByte(stream io.Reader) []byte {
	buf := new(bytes.Buffer)
	buf.ReadFrom(stream)
	return buf.Bytes()
}
{'fraction_non_alphanumeric': 0.1313246162592382, 'fraction_numerical': 0.0, 'mean_word_length': 4.238095238095238, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1950498', 'n_tokens_mistral': 660, 'n_tokens_neox': 642, 'n_words': 157}