Ejemplo n.º 1
0
        private void RaiseItemHandlingError(string path, MirrorAction action, Exception error)
        {
            var args = new ItemHandlingErrorArgs(path, action, error);
            EventHandler <ItemHandlingErrorArgs> handler = ItemHandlingError;

            if (handler != null)
            {
                handler(this, args);
            }
        }
Ejemplo n.º 2
0
        void OnItemHandlingError(object sender, ItemHandlingErrorArgs e)
        {
            //todo: make work for non-english
            if (!e.Exception.Message.Contains("too long") &&
                (e.Exception.Message.Contains("space") ||
                 e.Exception.Message.Contains("full")))
            {
                _progress.WriteError(e.Exception.Message);
                _gotIOExceptionProbablyDiskFull = true;
                _engine.Cancel();                        //will just end this group, not close the window
                return;
            }
            try
            {
                //for some reason many systems have these bogus "my videos", "my music", etc. links
                //which don't actually work.
                if (e.Exception is UnauthorizedAccessException)
                {
                    if (IsReparsePoint(e.Path))
                    {
                        //thinks like "my videos" junction in the windows 7 "my documents"
                        _progress.WriteVerbose("Skipping link/junction: '{0}'.", e.Path);
                        return;
                    }
                    else
                    {
                        _progress.WriteWarning(
                            "Could not access a directory or file: '{0}'. Reason={1}. Exception Follows:", e.Path,
                            e.Exception.Message);
                    }
                }
                else if (e.Exception is PathTooLongException)
                {
                    //we don't want to keep getting error reports, when the longpath stuff can't cope (not sure *why* it doesn't... maybe fat32 rather than ntfs on sticks?

                    _progress.WriteWarning(
                        "Windows could not handle this folder which is extremely deep: '{0}'. Reason={1}. Exception Follows:", e.Path,
                        e.Exception.Message);
                }
                else
                {
                    var msg = string.Format("Error while processing file'{0}'. Reason={1}. Exception Follows:", e.Path,
                                            e.Exception.Message);
                    _progress.WriteError(msg);
                    if (_firstErrorMessage != null)
                    {
                        _firstErrorMessage = msg;
                    }
                }
                if (e.Exception != null)
                {
                    _progress.WriteException(e.Exception);
                }

                _errorCountSinceLastSuccess++;
                if (_errorCountSinceLastSuccess > MaxErrorsBeforeAbort)
                {
                    _progress.WriteError("Error count exceeded limit. Will abort.");
                    _cancelRequested = true;
                    _engine.Cancel();
                }
            }
            catch (Exception error)
            {
                try
                {
                    _progress.WriteException(error);
                }
                catch (Exception progressException)
                {
                    SIL.Reporting.ErrorReport.ReportFatalException(progressException);
                }
            }
        }