<commit_before>package com.github.to2mbn.jyal.yggdrasil;

import org.json.JSONException;
import org.json.JSONObject;
import com.github.to2mbn.jyal.AuthenticationException;
import com.github.to2mbn.jyal.RemoteAuthenticationException;
import com.github.to2mbn.jyal.io.JSONHttpRequester;

abstract public class YggdrasilService {

	protected final JSONHttpRequester requester = new JSONHttpRequester();

	protected void checkResponse(JSONObject response) throws AuthenticationException {
		if (response == null) {
			throw new AuthenticationException("empty response");
		}

		try {
			if (response.has("error") && !response.getString("error").isEmpty()) {
				throw new RemoteAuthenticationException(response.getString("error"), response.optString("errorMessage"), response.optString("cause"));
			}
		} catch (JSONException e) {
			throw newResponseFormatException(e);
		}
	}

	protected AuthenticationException newResponseFormatException(Throwable e) {
		return new AuthenticationException("wrong response format", e);
	}

	protected AuthenticationException newRequestFailedException(Throwable e) {
		return new AuthenticationException("failed to request", e);
	}

	protected AuthenticationException newSignatureException(Throwable e) {
		return new AuthenticationException("failed to verify signature", e);
	}

}<commit_msg>fix errorMessage and cause will be "" instead of null<commit_after>package com.github.to2mbn.jyal.yggdrasil;

import org.json.JSONException;
import org.json.JSONObject;
import com.github.to2mbn.jyal.AuthenticationException;
import com.github.to2mbn.jyal.RemoteAuthenticationException;
import com.github.to2mbn.jyal.io.JSONHttpRequester;

abstract public class YggdrasilService {

	protected final JSONHttpRequester requester = new JSONHttpRequester();

	protected void checkResponse(JSONObject response) throws AuthenticationException {
		if (response == null) {
			throw new AuthenticationException("empty response");
		}

		try {
			if (response.has("error") && !response.getString("error").isEmpty()) {
				throw new RemoteAuthenticationException(response.getString("error"), response.optString("errorMessage", null), response.optString("cause", null));
			}
		} catch (JSONException e) {
			throw newResponseFormatException(e);
		}
	}

	protected AuthenticationException newResponseFormatException(Throwable e) {
		return new AuthenticationException("wrong response format", e);
	}

	protected AuthenticationException newRequestFailedException(Throwable e) {
		return new AuthenticationException("failed to request", e);
	}

	protected AuthenticationException newSignatureException(Throwable e) {
		return new AuthenticationException("failed to verify signature", e);
	}

}
{'fraction_non_alphanumeric': 0.09770540340488527, 'fraction_numerical': 0.0029607698001480384, 'mean_word_length': 6.385245901639344, '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': '139567', 'n_tokens_mistral': 779, 'n_tokens_neox': 737, 'n_words': 170}