Ejemplo n.º 1
0
        // error handling stolen from meldii
        // all hail the quinn
        private static void ErrorHandler(object sender, UnhandledExceptionEventArgs args)
        {
            Exception e = (Exception)args.ExceptionObject;

            File.WriteAllText(errorPath, ParseException(e));
            Error?.Invoke(e);
            Environment.Exit(0);
        }
Ejemplo n.º 2
0
        internal void HandleError(string errorMessage, Exception ex)
        {
            // log
            Log.Write(ERROR_LOG_CH, errorMessage);
            Log.WriteErr(ERROR_LOG_CH, ex);

            // send message to UI
            EncounteredError?.Invoke(errorMessage, ex);
        }
Ejemplo n.º 3
0
        private void SendError(Socket socket, Subheader sh, ErrorDelegate del)
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteInt((int)Header.Error);
            pw.WriteInt((int)sh);
            if (del != null)
            {
                del.Invoke(pw);
            }
            SendCustom(socket, pw.GetBytes(BUFFER_LENGTH));
        }
Ejemplo n.º 4
0
    private static IEnumerator DeleteRequest(string uri,
                                             CompleteDelegate completeDelegate = null, ErrorDelegate errorDelegateUri = null)
    {
        using (var www = UnityWebRequest.Delete(uri))
        {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
                errorDelegateUri?.Invoke(www.error);
            }
            else
            {
                Debug.Log("Upload complete!");
                completeDelegate?.Invoke(uri);
            }
        }
    }
Ejemplo n.º 5
0
        public static void ForEachFile(string gameDirectoryName, ProcessFileDelegate processDelegate, ErrorDelegate errorDelegate = null)
        {
            var archiveFileNames = Directory.GetFiles(gameDirectoryName, "*.rpf", SearchOption.AllDirectories);

            for (int i = 0; i < archiveFileNames.Length; i++)
            {
                try
                {
                    var fileName     = archiveFileNames[i];
                    var inputArchive = RageArchiveWrapper7.Open(fileName);
                    ForEachFile(fileName.Replace(gameDirectoryName, ""), inputArchive.Root, inputArchive.archive_.Encryption, processDelegate);
                    inputArchive.Dispose();
                }
                catch (Exception e)
                {
                    errorDelegate?.Invoke(e);
                }
            }
        }
Ejemplo n.º 6
0
        public bool WriteConfig()
        {
            LauncherSettingsFile sfile = new LauncherSettingsFile();

            // We read the existing file, if any. This allows settings beyond the scope of this screen to be saved
            try { sfile.ReadFromFile(Engine.SETTINGS_PATH); }
            catch { }

            if (spGamePath.Text != Resource.Strings.EmptyPath)
            {
                sfile.ExecutablePath = spGamePath.Text;
            }

            // Save
            try { sfile.WriteToFile(Engine.SETTINGS_PATH); }
            catch (Exception ex)
            {
                SaveError?.Invoke(Resource.Strings.Error_WriteConfig.F(ex.Message), ex);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
 public static void ForEachFile(string fullPathName, IArchiveDirectory directory, RageArchiveEncryption7 encryption, ProcessFileDelegate processDelegate, ErrorDelegate errorDelegate = null)
 {
     foreach (var file in directory.GetFiles())
     {
         processDelegate(fullPathName + "\\" + file.Name, file, encryption);
         if ((file is IArchiveBinaryFile) && file.Name.EndsWith(".rpf", StringComparison.OrdinalIgnoreCase))
         {
             try
             {
                 var fileStream   = ((IArchiveBinaryFile)file).GetStream();
                 var inputArchive = RageArchiveWrapper7.Open(fileStream, file.Name);
                 ForEachFile(fullPathName + "\\" + file.Name, inputArchive.Root, inputArchive.archive_.Encryption, processDelegate, errorDelegate);
             } catch (Exception e)
             {
                 errorDelegate?.Invoke(e);
             }
         }
     }
     foreach (var subDirectory in directory.GetDirectories())
     {
         ForEachFile(fullPathName + "\\" + subDirectory.Name, subDirectory, encryption, processDelegate);
     }
 }
Ejemplo n.º 8
0
        public void e1()
        {
            try
            {
                Random rnd = new Random();

                tab = new int[n2 - n1];

                for (int i = 0; i < n2 - n1; i++)
                {
                    tab[i] = rnd.Next(n1, n2);
                }
            }
            catch (NullReferenceException)
            {
                ed?.Invoke("Error 1");
            }
        }