<commit_before><?php

define( 'PHPME_FEATURE_NOT_SUPPORTED', 1 );
define( 'PHPME_REQUIRED_OPTION_UNDEFINED', 2 );
define( 'PHPME_HTTP_REQUEST_FAILED', 3 );

final class PHP_Merchant_Exception extends Exception {
	private static $messages = array(
		PHPME_FEATURE_NOT_SUPPORTED  => 'This payment gateway does not support "%s" feature.',
		PHPME_REQUIRED_OPTION_UNDEFINED => 'Missing required parameter: %s.',
		PHPME_HTTP_REQUEST_FAILED    => 'HTTP request failed: %s',
	);
	
	private $other_args;
	
	public function __construct( $code, $message_args = array(), $other_args = array() ) {
		$this->message_args = (array) $message_args;
		$this->message = vsprintf( self::$messages[$code], $this->message_args );
		$this->other_args = (array) $other_args;
	}
	
	public function getArguments() {
		return $this->other_args;
	}
}<commit_msg>- New exception code for invalid HTTP response - New method to add custom exception codes and messages via PHP_Merchant_Exception::addCodes()<commit_after><?php

define( 'PHPME_FEATURE_NOT_SUPPORTED', 1 );
define( 'PHPME_REQUIRED_OPTION_UNDEFINED', 2 );
define( 'PHPME_HTTP_REQUEST_FAILED', 3 );
define( 'PHPME_INVALID_RESPONSE', 4 );

final class PHP_Merchant_Exception extends Exception {
	private static $messages = array(
		PHPME_FEATURE_NOT_SUPPORTED     => 'This payment gateway does not support "%s" feature',
		PHPME_REQUIRED_OPTION_UNDEFINED => 'Missing required parameter: %s',
		PHPME_HTTP_REQUEST_FAILED       => 'HTTP request failed: %s',
		PHPME_INVALID_RESPONSE          => 'Invalid response from payment gateway',
	);
	
	public static function addCodes( $codes ) {
		if ( ! is_array( $codes ) )
			return;
		
		self::$message += $codes;
	}
	
	private $other_args;
	
	public function __construct( $code, $message_args = array(), $other_args = array() ) {
		$this->message_args = (array) $message_args;
		$this->message = vsprintf( self::$messages[$code], $this->message_args );
		$this->other_args = (array) $other_args;
		$this->code = $code;
		
		parent::__construct( $this->message, $code );
	}
	
	public function getArguments() {
		return $this->other_args;
	}
}
{'fraction_non_alphanumeric': 0.12942843646669816, 'fraction_numerical': 0.0033065658951346244, 'mean_word_length': 5.174927113702624, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '7016941', 'n_tokens_mistral': 722, 'n_tokens_neox': 689, 'n_words': 169}