Check block and throw PyrtlError or PyrtlInternalError if there is an issue.

        Should not modify anything, only check data structures to make sure they have been
        built according to the assumptions stated in the Block comments.
166191
def sanity_check(self):
        

        # TODO: check that the wirevector_by_name is sane
        from .wire import Input, Const, Output
        from .helperfuncs import get_stack, get_stacks

        # check for valid LogicNets (and wires)
        for net in self.logic:
            self.sanity_check_net(net)

        for w in self.wirevector_subset():
            if w.bitwidth is None:
                raise PyrtlError(
                    'error, missing bitwidth for WireVector "%s" \n\n %s' % (w.name, get_stack(w)))

        # check for unique names
        wirevector_names_set = set(x.name for x in self.wirevector_set)
        if len(self.wirevector_set) != len(wirevector_names_set):
            wirevector_names_list = [x.name for x in self.wirevector_set]
            for w in wirevector_names_set:
                wirevector_names_list.remove(w)
            raise PyrtlError('Duplicate wire names found for the following '
                             'different signals: %s' % repr(wirevector_names_list))

        # check for dead input wires (not connected to anything)
        all_input_and_consts = self.wirevector_subset((Input, Const))

        # The following line also checks for duplicate wire drivers
        wire_src_dict, wire_dst_dict = self.net_connections()
        dest_set = set(wire_src_dict.keys())
        arg_set = set(wire_dst_dict.keys())
        full_set = dest_set | arg_set
        connected_minus_allwires = full_set.difference(self.wirevector_set)
        if len(connected_minus_allwires) > 0:
            bad_wire_names = '\n    '.join(str(x) for x in connected_minus_allwires)
            raise PyrtlError('Unknown wires found in net:\n %s \n\n %s' % (bad_wire_names,
                             get_stacks(*connected_minus_allwires)))
        allwires_minus_connected = self.wirevector_set.difference(full_set)
        allwires_minus_connected = allwires_minus_connected.difference(all_input_and_consts)
        #   ^ allow inputs and consts to be unconnected
        if len(allwires_minus_connected) > 0:
            bad_wire_names = '\n    '.join(str(x) for x in allwires_minus_connected)
            raise PyrtlError('Wires declared but not connected:\n %s \n\n %s' % (bad_wire_names,
                             get_stacks(*allwires_minus_connected)))

        # Check for wires that are inputs to a logicNet, but are not block inputs and are never
        # driven.
        ins = arg_set.difference(dest_set)
        undriven = ins.difference(all_input_and_consts)
        if len(undriven) > 0:
            raise PyrtlError('Wires used but never driven: %s \n\n %s' %
                             ([w.name for w in undriven], get_stacks(*undriven)))

        # Check for async memories not specified as such
        self.sanity_check_memory_sync(wire_src_dict)

        if debug_mode:
            # Check for wires that are destinations of a logicNet, but are not outputs and are never
            # used as args.
            outs = dest_set.difference(arg_set)
            unused = outs.difference(self.wirevector_subset(Output))
            if len(unused) > 0:
                names = [w.name for w in unused]
                print('Warning: Wires driven but never used { %s } ' % names)
                print(get_stacks(*unused))
790801
@Override
  public void queryError(WebSocket session,
                         HeadersAmp headers,
                         String to,
                         long qid,
                         Throwable exn)
    throws IOException
  {
    /*
    try (Writer out = session.getBasicRemote().getSendWriter()) {
      init(out);
      queryError(headers, to, qid, exn);
    }
    */
  }
941435
protected void checkForBatchError(JsonNode root) {
		JsonNode errorCode = root.get("error");
		if (errorCode != null) {
			
			JsonNode errorDescription = root.get("error_description");
			if (errorDescription != null) {
				
				int code = errorCode.intValue();
				String msg = errorDescription.asText();

				this.throwCodeAndMessage(code, msg);
			}
		}
	}
664343
private function checkAndRegisterLineBreakErrors(): void
    {
        $tokens = $this->getTagTokens();
        $prevToken = [];
        $tagCounts = $this->docTagHelper->getTagCounts($tokens);
        $withReturn = false;

        foreach ($tokens as $tokenPos => $token) {
            $thisTagContent = $token['content'];
            $isReturn = $thisTagContent === '@return';

            $isGroupSwitch =
                // Did we switch the tag ...
                $prevToken && ($prevToken['content'] !== $thisTagContent) &&
                // ... but do we skip singles or are we entering the return block which should contain only 1 tag.
                (($tagCounts[$thisTagContent] !== 1) || ($isReturn && !$withReturn));

            // Insert new line between groups or before the return tag if there is no line break already.
            if ($isGroupSwitch && (($prevToken['line'] + 1) === $token['line'])) {
                $isFixing = $this->file->addFixableWarning(
                    static::MESSAGE_MISSING_NEWLINE_BETWEEN_TAGS,
                    $tokenPos,
                    static::CODE_MISSING_NEWLINE_BETWEEN_TAGS,
                    [
                        $prevToken['content']
                    ]
                );

                if ($isFixing) {
                    $this->insertNewLine($token);
                }
            }

            $prevToken = $token;
            // Return should be the last element, so this is ok.
            $withReturn = $isReturn;
        }
    }
478934
void reportChecksumFailure(String file, LocatedBlock lblocks[]) {
    try {
      reportBadBlocks(lblocks);
    } catch (IOException ie) {
      LOG.info("Found corruption while reading " + file
               + ".  Error repairing corrupt blocks.  Bad blocks remain. "
               + StringUtils.stringifyException(ie));
    }
  }
158845
static boolean isGeneralError(Symbol amqpError)
	{
		return (amqpError == ClientConstants.SERVER_BUSY_ERROR 
				|| amqpError == ClientConstants.TIMEOUT_ERROR 
				|| amqpError == AmqpErrorCode.ResourceLimitExceeded);
	}
1231690
@Override
	protected void checkHandle(int handle) throws DataStoreException
    {
        if (handle < 0 ||
            handle >= blockCount ||
            allocatedSize[handle] == -1 ||
            (flags[handle] & FLAG_START_BLOCK) == 0)
            throw new DataStoreException("Invalid handle : "+handle);
    }
1090135
private void checkFullBlock() throws BitcoinBlockReadException {
	// now we can check that we have a full block
		try {
			this.bin.mark(this.maxSizeBitcoinBlock);
			// skip maigc
			long skipMagic=this.bin.skip(4);
			if (skipMagic!=4) {
				 throw new BitcoinBlockReadException("Error: Cannot seek to a block start, because no valid block found. Cannot skip forward magic");
			}
		}
		catch (IOException e) {
			LOG.error(e);
			throw new BitcoinBlockReadException(e.toString());
		}
		// read size
		// blocksize
		byte[] blockSizeArray = new byte[4];
		try {
			
			int maxByteRead=4;
			int totalByteRead=0;
			int readByte;
			while ((readByte=this.bin.read(blockSizeArray,totalByteRead,maxByteRead-totalByteRead))>-1) {
					totalByteRead+=readByte;
					if (totalByteRead>=maxByteRead) {
						break;
					}
			}
			if (totalByteRead!=maxByteRead) {
				throw new BitcoinBlockReadException("Error: Cannot seek to a block start, because no valid block found. Cannot read size of block");
			} 
		}
		catch (IOException e) {
			LOG.error(e);
			throw new BitcoinBlockReadException(e.toString());
		}		
		long blockSize=BitcoinUtil.getSize(blockSizeArray);
		if (this.maxSizeBitcoinBlock<blockSize) {
			throw new BitcoinBlockReadException("Error: Cannot seek to a block start, because no valid block found. Max bitcoin block size is smaller than current block size.");
		}
		int blockSizeInt=(int)blockSize;
		byte[] blockRead=new byte[blockSizeInt];
		int totalByteRead=0;
		int readByte;
		try {
		while ((readByte=this.bin.read(blockRead,totalByteRead,blockSizeInt-totalByteRead))>-1) {
			totalByteRead+=readByte;
			if (totalByteRead>=blockSize) { 
				break;
			}
		}
		} catch (IOException e) {
			LOG.error(e);
			throw new BitcoinBlockReadException(e.toString());
		}
		if (totalByteRead!=blockSize) {
			 throw new BitcoinBlockReadException("Error: Cannot seek to a block start, because no valid block found. Cannot skip to end of block");
		}
		try {
			this.bin.reset();
		} catch (IOException e) {
			LOG.error(e);
			throw new BitcoinBlockReadException(e.toString());
		}
		// it is a full block
}
440724
def checkError(barcode, whitelist, errors=1):
    '''
    
    '''

    near_matches = []
    comp_regex = regex.compile("(%s){e<=%i}" % (barcode, errors))
    b_length = len(barcode)
    for whitelisted_barcode in whitelist:
        w_length = len(whitelisted_barcode)

        # Don't check against itself
        if barcode == whitelisted_barcode:
            continue

        # If difference in barcode lengths > number of allowed errors, continue
        if (max(b_length, w_length) > (min(b_length, w_length) + errors)):
            continue
        if comp_regex.match(whitelisted_barcode):
            near_matches.append(whitelisted_barcode)

            # Assuming downstream processes are the same for
            # (>1 -> Inf) near_matches this is OK
            if len(near_matches) > 1:
                return near_matches

    return near_matches
127014
@Override
    public void onRPCError(int handle, int code, String text) {
        if (handle == asyncHandle) {
            asyncHandle = 0;
            ZKUtil.fireEvent(new AsyncRPCErrorEvent(rpcName, target, code, text, handle));
            rpcName = null;
        }
    }
553884
function it_throwsErrorIfVertexExists() {
			it("throws an error if a vertex with the given key already exists", function () {
				expectItWhenBoundWith('k1').toThrow();
				expectItWhenBoundWith('k2').toThrow();
				expectItWhenBoundWith('k1').toThrowSpecific(Graph.VertexExistsError, { vertices: {'k1': 'oldValue1'} });
				expectItWhenBoundWith('k2').toThrowSpecific(Graph.VertexExistsError, { vertices: {'k2': undefined} });
			});
		}
611324
function it_throwsErrorIfEdgeExists() {
			it("throws an error if an edge with the given keys already exists", function () {
				expectItWhenBoundWith('k2', 'k3').toThrow();
				expectItWhenBoundWith('k3', 'k4').toThrow();
				expectItWhenBoundWith('k2', 'k3').toThrowSpecific(Graph.EdgeExistsError, { edges: {'k2': {'k3': 'oldValue23'}} });
				expectItWhenBoundWith('k3', 'k4').toThrowSpecific(Graph.EdgeExistsError, { edges: {'k3': {'k4': undefined}} });
			});
		}
917175
private boolean isApplicationError(Throwable rootEx, String pkgRoot) {
        
        if (rootEx != null) {
            StackTraceElement[] stackTrace = rootEx.getStackTrace();
            if (stackTrace != null && stackTrace.length > 0) {
                StackTraceElement rootThrower = stackTrace[0];
                String className = rootThrower.getClassName();
                if (className != null && !!!className.startsWith(pkgRoot)) {
                    return true;
                }
            }
        }
        
        return false;
    }
706687
def _check_for_errors(etree: ET.ElementTree):
    """"""
    if etree.getroot().tag == 'error':
        raise APIError(etree.getroot().text)
1304385
def _sanity_check_query_root_block(ir_blocks):
    """"""
    if not isinstance(ir_blocks[0], QueryRoot):
        raise AssertionError(u'The first block was not QueryRoot: {}'.format(ir_blocks))
    for block in ir_blocks[1:]:
        if isinstance(block, QueryRoot):
            raise AssertionError(u'Found QueryRoot after the first block: {}'.format(ir_blocks))
1033743
def _checkIfCode(self, inCodeBlockObj):
        """"""
        while True:
            line, lines, lineNum = (yield)
            testLineNum = 1
            currentLineNum = 0
            testLine = line.strip()
            lineOfCode = None
            while lineOfCode is None:
                match = AstWalker.__errorLineRE.match(testLine)
                if not testLine or testLine == '...' or match:
                    # These are ambiguous.
                    line, lines, lineNum = (yield)
                    testLine = line.strip()
                    #testLineNum = 1
                elif testLine.startswith('>>>'):
                    # This is definitely code.
                    lineOfCode = True
                else:
                    try:
                        compLine = compile_command(testLine)
                        if compLine and lines[currentLineNum].strip().startswith('#'):
                            lineOfCode = True
                        else:
                            line, lines, lineNum = (yield)
                            line = line.strip()
                            if line.startswith('>>>'):
                                # Definitely code, don't compile further.
                                lineOfCode = True
                            else:
                                testLine += linesep + line
                                testLine = testLine.strip()
                                testLineNum += 1
                    except (SyntaxError, RuntimeError):
                        # This is definitely not code.
                        lineOfCode = False
                    except Exception:
                        # Other errors are ambiguous.
                        line, lines, lineNum = (yield)
                        testLine = line.strip()
                        #testLineNum = 1
                currentLineNum = lineNum - testLineNum
            if not inCodeBlockObj[0] and lineOfCode:
                inCodeBlockObj[0] = True
                lines[currentLineNum] = '{0}{1}# @code{1}'.format(
                    lines[currentLineNum],
                    linesep
                )
            elif inCodeBlockObj[0] and lineOfCode is False:
                # None is ambiguous, so strict checking
                # against False is necessary.
                inCodeBlockObj[0] = False
                lines[currentLineNum] = '{0}{1}# @endcode{1}'.format(
                    lines[currentLineNum],
                    linesep
                )
931345
def check_for_errors(response) #:nodoc
      case response.status
        when 400 then raise HTTPRequestFailed, response.body
        when 403 then parse_403_error(response)
        when 404 then raise HTTPNotFound, response.body
        when 409 then raise RequestedIdentifierAlreadyExistsError, response.body
        when 410 then raise GoneError, response.body
        when 412 then raise PreconditionFailedError, response.body
        when 500 then raise BackendError, response.body
      end
    end