'Build a new ErrorDescriptor. using ``system``.
Arguments:
system (:class:`DescriptorSystem`): The :class:`DescriptorSystem` used
to construct the XBlock that had an error.
contents (unicode): An encoding of the content of the xblock that had an error.
error_msg (unicode): A message describing the error.
location (:class:`UsageKey`): The usage key of the XBlock that had an error.
for_parent (:class:`XBlock`): Optional. The parent of this error block.'

@classmethod
def _construct(cls, system, contents, error_msg, location, for_parent=None):

    if (error_msg is None):
        error_msg = 'Error    not    available'
    if (location.category == 'error'):
        location = location.replace(name=hashlib.sha1(contents.encode('utf8')).hexdigest())
    field_data = DictFieldData({'error_msg': unicode(error_msg), 'contents': contents, 'location': location, 'category': 'error'})
    return system.construct_xblock_from_class(cls, ScopeIds(None, 'error', location, location), field_data, for_parent=for_parent)
