def create_exception(error_codec):
    """
    Creates an exception with given error codec.

    :param error_codec: (Error Codec), error codec which includes the class name, message and exception trace.
    :return: (Exception), the created exception.
    """
    if error_codec.error_code in ERROR_CODE_TO_ERROR:
        return ERROR_CODE_TO_ERROR[error_codec.error_code](error_codec.message)

    stack_trace = "\n".join(
        ["\tat %s.%s(%s:%s)" % (x.declaring_class, x.method_name, x.file_name, x.line_number) for x in
         error_codec.stack_trace])
    message = "Got exception from server:\n %s: %s\n %s" % (error_codec.class_name,
                                                            error_codec.message,
                                                            stack_trace)
    return HazelcastError(message)
Creates an exception with given error codec.

    :param error_codec: (Error Codec), error codec which includes the class name, message and exception trace.
    :return: (Exception), the created exception.