<commit_before>import json

class ApiBaseException(Exception):
	def __init__(self, message = 'Something went wrong. Please call customer support.'):
		super(ApiBaseException, self).__init__(message)
		
	def json(self):
		return self.message
		#

		### Do some crazy logging in here

class InternalErrorException(ApiBaseException):
	def __init__(self):
		super(InternalErrorException, self).__init__('Sorry, something went wrong. Please call technical support!')

class UnknownUnitException(ApiBaseException):
	def __init__(self, supplied_unit):
		super(UnknownUnitException, self).__init__('Bad unit specified: %s'%supplied_unit)

class InvalidAttributeException(ApiBaseException):
	def __init__(self, attribute):
		super(InvalidAttributeException, self).__init__('"%s" has no meaning or is not allowed the context of the current request.'%attribute)

class MissingNodeException(ApiBaseException):
	def __init__(self, node_id):
		super(MissingNodeException, self).__init__('No such node: %s'%node_id)

	# def __repr__(self):
	# 	return json.dumps({'error': self.message})<commit_msg>Pimped InvalidAttributeException to give better feedback info<commit_after>import json

class ApiBaseException(Exception):
	def __init__(self, message = 'Something went wrong. Please call customer support.'):
		super(ApiBaseException, self).__init__(message)
		
	def json(self):
		return self.message
		#

		### Do some crazy logging in here

class InternalErrorException(ApiBaseException):
	def __init__(self):
		super(InternalErrorException, self).__init__('Sorry, something went wrong. Please call technical support!')

class UnknownUnitException(ApiBaseException):
	def __init__(self, supplied_unit):
		super(UnknownUnitException, self).__init__('Bad unit specified: %s'%supplied_unit)

class InvalidAttributeException(ApiBaseException):
	def __init__(self, attribute, model = None):
		message = '"%s" has no meaning or is not allowed the context of the current request.'%attribute
		if model: 
			message += ' Valid parameters for model %s are: %s'%(model.__name__, model.settables())
		super(InvalidAttributeException, self).__init__(message)

class MissingNodeException(ApiBaseException):
	def __init__(self, node_id):
		super(MissingNodeException, self).__init__('No such node: %s'%node_id)

	# def __repr__(self):
	# 	return json.dumps({'error': self.message})
{'fraction_non_alphanumeric': 0.10671768707482993, 'fraction_numerical': 0.0, 'mean_word_length': 6.689542483660131, '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': '3766214', 'n_tokens_mistral': 701, 'n_tokens_neox': 670, 'n_words': 188}