Wand library makes sure when opening any image that is fine, when
        the image is corrupted raises an exception.
179434
def is_valid_image(self, raw_data):
        '''
        
        '''

        try:
            Image(blob=raw_data)
            return True
        except (exceptions.CorruptImageError, exceptions.MissingDelegateError):
            return False
200509
def check(self, pointer, expected, raise_onerror=False):
        
        obj = self.document
        for token in Pointer(pointer):
            try:
                obj = token.extract(obj, bypass_ref=True)
            except ExtractError as error:
                if raise_onerror:
                    raise Error(*error.args)
                logger.exception(error)
                return False
        return obj == expected
293334
def _on_dynamodb_exception(self, error):
        
        if isinstance(error, exceptions.ConditionalCheckFailedException):
            raise web.HTTPError(409, reason='Condition Check Failure')
        elif isinstance(error, exceptions.NoCredentialsError):
            if _no_creds_should_return_429():
                raise web.HTTPError(429, reason='Instance Credentials Failure')
        elif isinstance(error, (exceptions.ThroughputExceeded,
                                exceptions.ThrottlingException)):
            raise web.HTTPError(429, reason='Too Many Requests')
        if hasattr(self, 'logger'):
            self.logger.error('DynamoDB Error: %s', error)
        raise web.HTTPError(500, reason=str(error))
338062
protected void showError (Throwable cause, Widget near)
    {
        if (near == null) {
            Popups.error(formatError(cause));
        } else {
            Popups.errorBelow(formatError(cause), near);
        }
    }
1328053
private void interruptImageValidation() throws IOException {
    synchronized (imageValidatorLock) {
      if (imageValidator != null) {
        imageValidator.interrupt();
        try {
          imageValidator.join();
        } catch (InterruptedException e) {
          throw new InterruptedIOException("Standby: received interruption");
        }
      }
    }
  }
1132747
private void checkFileReopening(FileObject fileObject, boolean addToHistory) throws FilerException {
        for(FileObject veteran : fileObjectHistory) {
            if (fileManager.isSameFile(veteran, fileObject)) {
                if (lint)
                    log.warning("proc.file.reopening", fileObject.getName());
                throw new FilerException("Attempt to reopen a file for path " + fileObject.getName());
            }
        }
        if (addToHistory)
            fileObjectHistory.add(fileObject);
    }
530240
public void handleExceptionWithRecordProcess(Exception e, Object w)
      {
        final String mName = "handleExceptionWithRecordProcess";
        if(logger.isLoggable(Level.FINER)) 
          logger.logp(Level.FINE, className, mName, e.getClass().getName() + "; " + this.toString());

        if (!isSkipLimitReached() && excMatcher.isSkippableOrRetryable(e))
        {
          // Skip it.  Log it.  Call the SkipProcessListener.
          ++_skipCount;
          logSkip(e);

          if (_skipProcessListener != null) {
              for (SkipProcessListenerProxy skipProcessListenerProxy : _skipProcessListener) {
                  skipProcessListenerProxy.onSkipProcessItem(w, e);
                }
          }
        }
        else
        {
          // No skip.  Throw it back.
          if(logger.isLoggable(Level.FINER)) 
            logger.logp(Level.FINE, className, mName, "No skip.  Rethrow ", e);
          throw new BatchContainerRuntimeException(e);
        }
      }
727352
def checkmagic(self):
        
        self.lib.seek(self.start)  # default - magic is at start of file

        if self.lib.read(len(self.MAGIC)) != self.MAGIC:
            raise ArchiveReadError("%s is not a valid %s archive file"
                                   % (self.path, self.__class__.__name__))

        if self.lib.read(len(self.pymagic)) != self.pymagic:
            raise ArchiveReadError("%s has version mismatch to dll" %
                (self.path))

        self.lib.read(4)
894977
def _check_image(self, image_nD):
        """"""

        self.input_image = load_image_from_disk(image_nD)

        if len(self.input_image.shape) < 3:
            raise ValueError('Input image must be atleast 3D')

        if np.count_nonzero(self.input_image) == 0:
            raise ValueError('Input image is completely filled with zeros! '
                             'Must be non-empty')
1187628
private void handleReopenForStorageException(final StorageException exs) throws StorageException {
    reopens++;
    if (reopens > maxReopens) {
      throw new StorageException(
          exs.getCode(),
          "All "
              + maxReopens
              + " reopens failed. Waited a total of "
              + totalWaitTime
              + " ms between attempts",
          exs);
    }
    sleepForAttempt(reopens);
  }
374619
def _handle_run_exception(self, exc):
        
        if len(self._current_tups) == 1:
            tup = self._current_tups[0]
            self.raise_exception(exc, tup)
            if self.auto_fail:
                self.fail(tup)
503932
def check_reference(images, reference):
    
    if not images.shape[1:] == reference.shape:
        raise Exception('Image shape %s and reference shape %s must match'
                        % (images.shape[1:], reference.shape))
    return reference
308387
def check_images(data):
    
    if isinstance(data, ndarray):
        data = fromarray(data)
    
    if not isinstance(data, Images):
        data = fromarray(asarray(data))

    if len(data.shape) not in set([3, 4]):
        raise Exception('Number of image dimensions %s must be 2 or 3' % (len(data.shape)))

    return data
215747
def raises_gathered(error_type):
    ''''''
    container = RaisesGatheredContainer()
    try:
        yield container
    except GatheredExceptions as e:
        # Make sure there is exactly one exception.
        if len(e.exceptions) != 1:
            raise
        inner = e.exceptions[0]
        # Make sure the exception is the right type.
        if not isinstance(inner, error_type):
            raise
        # Success.
        container.exception = inner
448606
private void checkAllowedNonFileState(StorageState curState, Object name)
      throws IOException {
    switch (curState) {
    case NON_EXISTENT:
    case NOT_FORMATTED:
    case NORMAL:
      break;
    default:
      throwIOException("ImageManager bad state: " + curState + " for: "
          + name.toString());
    }
  }
533650
def RaiseIfNotErrorSuccess(result, func = None, arguments = ()):
    
    if result != ERROR_SUCCESS:
        raise ctypes.WinError(result)
    return result
966454
protected function fileExistsAndReadable ()
	{
		if ($this->isDataStream === true)
		{
			return;
		}
		
		if (stristr($this->fileName, 'http://') !== false)
		{
			$this->remoteImage = true;
			return;
		}
		
		if (!file_exists($this->fileName))
		{
			$this->triggerError('Image file not found: ' . $this->fileName);
		}
		elseif (!is_readable($this->fileName))
		{
			$this->triggerError('Image file not readable: ' . $this->fileName);
		}
	}