Handler for catching file-not-found errors and throwing an IncludeException
17012
public static function IncludeException($code, $string, $file, $line, $context)
	{
		// check for repressed errors
		if (error_reporting() == 0) return;
		
		$tmp1 = explode(")",$string);
		$tmp2 = explode("(",$tmp1[0]);
		$mfile = isset($tmp2[1]) ? $tmp2[1] : "";
		
		$msg = "Error $code: " .  ($mfile ? "Unable to include file: '" . $mfile . "'" : $string);
		
		throw new IncludeException($msg,$code);
	}
632887
def error_catcher(self, extra_info: Optional[str] = None):
        
        try:
            yield
        except InstaloaderException as err:
            if extra_info:
                self.error('{}: {}'.format(extra_info, err))
            else:
                self.error('{}'.format(err))
            if self.raise_all_errors:
                raise
1363790
private void handleActionException(String target, HttpServletRequest request, HttpServletResponse response, Action action, ActionException e) {
		int errorCode = e.getErrorCode();
		String msg = null;
		if (errorCode == 404) {
			msg = "404 Not Found: ";
		} else if (errorCode == 400) {
			msg = "400 Bad Request: ";
		} else if (errorCode == 401) {
			msg = "401 Unauthorized: ";
		} else if (errorCode == 403) {
			msg = "403 Forbidden: ";
		}
		
		if (msg != null) {
			if (log.isWarnEnabled()) {
				String qs = request.getQueryString();
				msg = msg + (qs == null ? target : target + "?" + qs);
				if (e.getMessage() != null) {
					msg = msg + "\n" + e.getMessage();
				}
				log.warn(msg);
			}
		} else {
			if (log.isErrorEnabled()) {
				String qs = request.getQueryString();
				log.error(errorCode + " Error: " + (qs == null ? target : target + "?" + qs), e);
			}
		}
		
		e.getErrorRender().setContext(request, response, action.getViewPath()).render();
	}
675688
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = null)
    {
        // throwing an exception in an error handler will halt execution
        //   set the last error and continue
        $this->last_error = compact('errno', 'errstr', 'errfile', 'errline', 'errcontext');
    }
1121101
def error_handler(task):
    """"""
    @wraps(task)
    def wrapper(self, *args, **kwargs):
        try:
            return task(self, *args, **kwargs)
        except Exception as e:
            self.connected = False
            if not self.testing:
                exc_type, exc_obj, exc_tb = sys.exc_info()
                fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                error_message = (
                    "[" + str(datetime.now()) + "] Error in task \"" +
                    task.__name__ + "\" (" +
                    fname + "/" + str(exc_tb.tb_lineno) +
                    ")" + e.message
                )
                self.logger.error("%s: RPC instruction failed" % error_message)
    return wrapper
454249
def handle_unexpected_exception(exc):
    # type: (BaseException) -> str
    
    try:
        write_logfile()
        addendum = 'Please see the log file for more information.'
    except IOError:
        addendum = 'Unable to write log file.'
    try:
        message = str(exc)
        return '{}{}{}'.format(message, '\n' if message else '', addendum)
    except Exception:  # pylint: disable=broad-except
        return str(exc)
1205446
def _except_if_failed(cls, event):
        """"""
        if event.success is None:
            raise IOTSyncTimeout('Requested timed out', event)
        if not event.success:
            msg = "Request failed, unknown error"
            if isinstance(event.payload, Mapping):
                if P_MESSAGE in event.payload:
                    msg = event.payload[P_MESSAGE]
                try:
                    exc_class = cls.__exception_mapping[event.payload[P_CODE]]
                except KeyError:
                    pass
                else:
                    raise exc_class(msg, event)

            raise IOTException(msg, event)
645754
def report_exception(self, filename, exc):
        
        # Build fake event.
        event = AbinitError(src_file="Unknown", src_line=0, message=str(exc))
        return EventReport(filename, events=[event])
149536
def exception_handler(self, pdb):
        '''
        

        '''

        # Grab the exception
        exctype, value, tb = sys.exc_info()

        # Log the error and create a .err file
        errfile = os.path.join(self.dir, self.name + '.err')
        with open(errfile, 'w') as f:
            for line in traceback.format_exception_only(exctype, value):
                ln = line.replace('\n', '')
                log.error(ln)
                print(ln, file=f)
            for line in traceback.format_tb(tb):
                ln = line.replace('\n', '')
                log.error(ln)
                print(ln, file=f)

        # Re-raise?
        if pdb:
            raise
609547
def rmtree_errorhandler(func, path, exc_info):
    """"""
    exctype, value = exc_info[:2]
    # On Python 2.4, it will be OSError number 13
    # On all more recent Pythons, it'll be WindowsError number 5
    if not ((exctype is WindowsError and value.args[0] == 5) or
            (exctype is OSError and value.args[0] == 13)):
        raise
    # file type should currently be read only
    if ((os.stat(path).st_mode & stat.S_IREAD) != stat.S_IREAD):
        raise
    # convert to read/write
    os.chmod(path, stat.S_IWRITE)
    # use the original function to repeat the operation
    func(path)
22862
def call_and_catch_errors(self, f, *args, **kwargs):
        
        try:
            return f(*args, **kwargs)
        except SassError as e:
            if self.live_errors:
                # TODO should this setting also capture and display warnings?
                return e.to_css()
            else:
                raise
1112569
private static void handleFrameworkException(final FrameworkException fex, final String name) throws IOException {

		switch (fex.getStatus()) {

			case 401:
			case 403:
				throw new AccessDeniedException(name);

			case 404:
				throw new NoSuchFileException(name);

			default:
				throw new IllegalArgumentException(fex.getMessage());
		}
	}
67919
function fileExists(file, handle) {
		fs.exists(file, function(exists) {
			handle.apply(null, exists ? [file] : []);
		});
	}
1130282
def findAllExceptions(pathToCheck):
    
    finder = PatternFinder()
    if os.path.isfile(pathToCheck):
        with open(pathToCheck) as f:
            findPatternsInFile(f.read(), finder)
    else:
        for path, dirs, files in os.walk(pathToCheck):
            for file in files:
                _, extname = os.path.splitext(file)
                if extname == ".py":
                    pathFile = os.path.join(path, file)
                    with open(pathFile) as f:
                        findPatternsInFile(f.read(), finder)
    return finder.patternsFunc, finder.patternsClass
963114
function handleFile(name, file, options, cache, callback) {
	var cachedData;
	if(!options || !options.settings || options.settings['view cache'] !== false) {
		cachedData = cache && cache.get(file);
	}
	if (!cachedData) {
		loadFile(file, function(err, fileData) {
			if (err) {
				return callback(err);
			}

			var partials;
			try {
				partials = findPartials(fileData);
			} catch (err) {
				return callback(err);
			}

			var data = {
				name: name,
				data: fileData,
				partials: partials
			};
			if (cache) {
				cache.set(file, data);
			}
			return callback(null, data);
		});
	}
	else {
		return callback(null, cachedData);
	}
}
1309709
def _run_lint_on_file(file_path,
                      linter_functions,
                      tool_options,
                      fix_what_you_can):
    
    with io.open(file_path, "r+", encoding="utf-8") as found_file:
        file_contents = found_file.read()
        file_lines = file_contents.splitlines(True)
        try:
            errors = lint(file_path[len(os.getcwd()) + 1:],
                          file_contents,
                          linter_functions,
                          **tool_options)
        except RuntimeError as err:
            msg = ("""RuntimeError in processing {0} - {1}""".format(file_path, str(err)))
            errors = [("polysquarelinter/failure",
                       LinterFailure(msg, 0, None))]

        if fix_what_you_can:
            for error_index, error in enumerate(errors):
                if error[1].replacement is not None:
                    _apply_replacement(error, found_file, file_lines)
                    errors[error_index] = (error[0],
                                           LinterFailure(error[1].description +
                                                         " ... FIXED",
                                                         error[1].line,
                                                         error[1].replacement))
                    break

        return [FileLinterFailure(file_path, e) for e in errors]
795522
function error (err, file, name, options) {
  var message = err.message
  var column = err.column
  var line = err.line
  var type = err.name
  var method = 'message'

  if (options.throws) {
    method = 'fail'
  }

  file[method](
    message,
    { line: line, column: column },
    'parseFrontMatter:' + name + ':' + type
  )
}