<commit_before>package s3util

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

type respError struct {
	r *http.Response
	b bytes.Buffer
}

func newRespError(r *http.Response) *respError {
	e := new(respError)
	e.r = r
	io.Copy(&e.b, r.Body)
	r.Body.Close()
	return e
}

func (e *respError) Error() string {
	return fmt.Sprintf(
		"unwanted http status %d: %q",
		e.r.StatusCode,
		e.b.String(),
	)
}

func (e *respError) StatusCode() int {
	return e.r.StatusCode
}
<commit_msg>Add method to get response code from error interface<commit_after>package s3util

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

type respError struct {
	r *http.Response
	b bytes.Buffer
}

func newRespError(r *http.Response) *respError {
	e := new(respError)
	e.r = r
	io.Copy(&e.b, r.Body)
	r.Body.Close()
	return e
}

func (e *respError) Error() string {
	return fmt.Sprintf(
		"unwanted http status %d: %q",
		e.r.StatusCode,
		e.b.String(),
	)
}

func (e *respError) StatusCode() int {
	return e.r.StatusCode
}

func GetRespCode(e error) int {
	err, ok := e.(*respError)
	if !ok {
		return 0
	}

	return err.StatusCode()
}

{'fraction_non_alphanumeric': 0.15321849501359927, 'fraction_numerical': 0.0027198549410698096, 'mean_word_length': 3.54320987654321, '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': '2525943', 'n_tokens_mistral': 473, 'n_tokens_neox': 463, 'n_words': 117}