Example #1
0
 public static void LogException(Exception e)
 {
     Debug.LogException(e);
     #if STENCIL_FIREBASE
     Crashlytics.LogException(e);
     #endif
 }
Example #2
0
        private void CheckFile()
        {
            if (CheckLength() == false)
            {
                Debug.LogException(new Exception("CheckFile===>CheckLength Error Url->" + Url));
                Retry();
                return;
            }

            LoadingProgress.Instance.SetDownloadText(I18NManager.Get("Download_CheckFiles"));

            Loom.RunAsync(() =>
            {
                Stopwatch sw = Stopwatch.StartNew();

                bool md5Fixed = CheckMd5();

                Loom.QueueOnMainThread(() =>
                {
                    Debug.LogWarning("===CheckFile CheckMd5耗时:" + sw.ElapsedMilliseconds + "ms Url->" + Url);

                    if (md5Fixed)
                    {
                        _onComplete?.Invoke(this);
                    }
                    else
                    {
                        Debug.LogException(new Exception("CheckFile===>md5Fixed Error Url->" + Url));
                        Retry();
                    }
                });
            });
        }
        public SfbFileSystemEntry CreateNewFileAndAddEntry(string path)
        {
            if (entries.ContainsKey(path))
            {
                Debug.LogWarning("File already exists");
                return(null);
            }

            SfbFileSystemEntry entry = new SfbFileSystemEntry(path, false, SfbFileSystemEntryType.File);

#if !UNITY_WEBGL && !UNITY_WEBPLAYER
            if (!IsFake)
            {
                try {
                    File.Create(path);
                }
                catch (Exception e) {
                    Debug.LogException(e);
                    Debug.LogError("Could not create file");
                    return(null);
                }
            }
#endif

            AddEntry(entry);
            return(entry);
        }
Example #4
0
        public static void Process()
        {
            stopwatch.Reset();
            stopwatch.Start();

            while (highPriority.TryDequeue(out var action))
            {
                try
                {
                    action();
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }

            while (stopwatch.Elapsed < lowPriorityMaxDuration && lowPriority.TryDequeue(out var action))
            {
                try
                {
                    action();
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
        }
Example #5
0
 /// <summary>
 /// Writes exception to console. Works only when Debugger is Enabled.
 /// </summary>
 /// <param name="exception">Exception to write.</param>
 /// <param name="context">Context.</param>
 public static void LogException(Exception exception, Object context = null)
 {
     if (LogLevelEnabled(LogLevel.Exception))
     {
         Debug.LogException(exception, context);
     }
 }
Example #6
0
        protected override void Clean(string path, string root, Stream input, Stream output)
        {
            try
            {
                Process    process;
                FilterMode mode;
                if (!processes.TryGetValue(path, out process))
                {
                    Debug.Log("Could not find lfs process for path: " + path + " when cleaning");
                    return;
                }

                if (!modes.TryGetValue(path, out mode))
                {
                    Debug.Log("Could not find lfs filter mode for path: " + path + " when cleaning");
                    return;
                }

                if (mode != FilterMode.Clean)
                {
                    Debug.LogError("Filter mode mismatch when cleaning for path: " + path);
                }

                // write file data to stdin
                input.CopyTo(process.StandardInput.BaseStream);
                input.Flush();
            }
            catch (Exception e)
            {
                Debug.LogError("LFS Clean Error!");
                Debug.LogException(e);
            }
        }
Example #7
0
        protected override void Complete(string path, string root, Stream output)
        {
            try
            {
                Process    process;
                FilterMode mode;

                if (!processes.TryGetValue(path, out process))
                {
                    throw new Exception("Could not find lfs process for path: " + path);
                }

                if (!modes.TryGetValue(path, out mode))
                {
                    throw new Exception("Could not find lfs filter mode for path: " + path);
                }

                process.StandardInput.Flush();
                process.StandardInput.Close();

                // finalize stdin and wait for git-lfs to finish
                if (mode == FilterMode.Clean)
                {
                    // write git-lfs pointer for 'clean' to git or file data for 'smudge' to working copy
                    process.StandardOutput.BaseStream.CopyTo(output);
                    process.StandardOutput.BaseStream.Flush();
                    process.StandardOutput.Close();
                    output.Flush();
                    output.Close();

                    process.WaitForExit();
                }
                else if (mode == FilterMode.Smudge)
                {
                    // write git-lfs pointer for 'clean' to git or file data for 'smudge' to working copy
                    process.StandardOutput.BaseStream.CopyTo(output);
                    process.StandardOutput.BaseStream.Flush();
                    process.StandardOutput.Close();
                    output.Flush();
                    output.Close();

                    process.WaitForExit();
                }

                process.Dispose();
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception e)
            {
                Debug.LogError("LFS Complete Error!");
                Debug.LogException(e);
            }
            finally
            {
                processes.Remove(path);
                modes.Remove(path);
            }
        }
Example #8
0
        public IAPOfferInfo(string infoString) : this()
        {
            if (string.IsNullOrEmpty(infoString))
            {
                return;
            }

            try
            {
                var   pars = infoString.Split(',');
                float pp;
                int   ia;
                long  st, et;

                ProductId    = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[0]));
                ProductPrice = float.TryParse(pars[1], out pp) ? pp : 0f;
                ItemName     = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[2]));
                ItemAmount   = int.TryParse(pars[3], out ia) ? ia : 0;
                StartTime    = (long.TryParse(pars[4], out st) ? st : 0).ToDateTime();
                EndTime      = (long.TryParse(pars[5], out et) ? et : 0).ToDateTime();
                Metadata     = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[6]));
            }
            catch (Exception e)
            {
                Debug.LogError("FuseSDK: Error parsing IAPOfferInfo. Returning default value.");
                Debug.LogException(e);
                return;
            }
        }
        public static bool WriteShaderGraphToDisk <T>(string path, T data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            CheckoutIfValid(path);

            try
            {
                File.WriteAllText(path, EditorJsonUtility.ToJson(data, true));
            }
            catch (Exception e)
            {
                if (e.GetBaseException() is UnauthorizedAccessException &&
                    (File.GetAttributes(path) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    FileInfo fileInfo = new FileInfo(path);
                    fileInfo.IsReadOnly = false;
                    File.WriteAllText(path, EditorJsonUtility.ToJson(data, true));
                    return(true);
                }
                Debug.LogException(e);
                return(false);
            }
            return(true);
        }
Example #10
0
        private static void UnzipBackendStep(Dictionary <string, ResPack> dict, string fileKey,
                                             Action <Dictionary <string, ResPack> > onUnzipComplete)
        {
            ResPack resPack  = dict[fileKey];
            string  filePath = AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath;

            Loom.RunAsync(() =>
            {
                try
                {
                    ZipUtil.UnzipThread(filePath, AssetLoader.ExternalHotfixPath + "/" + resPack.releasePath);
                }
                catch (IOException e)
                {
                    Debug.LogException(e);
                }

                Loom.QueueOnMainThread(() =>
                {
                    File.Delete(filePath);
                    FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend + "_" + fileKey);
                    fm.UpdateRecord(AppConfig.Instance.version + "");

                    onUnzipComplete?.Invoke(dict);
                });
            });
        }
Example #11
0
        public VGOfferInfo(string infoString) : this()
        {
            if (string.IsNullOrEmpty(infoString))
            {
                return;
            }

            try
            {
                var   pars = infoString.Split(',');
                float pp;
                int   ia;
                long  st, et;
                int   cid, vgid;

                PurchaseCurrency = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[0]));
                PurchasePrice    = float.TryParse(pars[1], out pp) ? pp : 0f;
                ItemName         = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[2]));
                ItemAmount       = int.TryParse(pars[3], out ia) ? ia : 0;
                StartTime        = (long.TryParse(pars[4], out st) ? st : 0).ToDateTime();
                EndTime          = (long.TryParse(pars[5], out et) ? et : 0).ToDateTime();
                CurrencyID       = int.TryParse(pars[6], out cid) ? cid : 0;
                VirtualGoodID    = int.TryParse(pars[7], out vgid) ? vgid : 0;
                Metadata         = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(pars[8]));
            }
            catch (Exception e)
            {
                Debug.LogError("FuseSDK: Error parsing VGOfferInfo. Returning default value.");
                Debug.LogException(e);
                return;
            }
        }
Example #12
0
        private static object[] NotifyLocalListeners(string eventType, object[] data, bool notifyWildcard)
        {
            List <OnHandler> handlers = null;
            var result = new object[0];

            if (s_Events.TryGetValue(eventType, out handlers))
            {
                try
                {
                    result = handlers.Select(handler => handler(eventType, data)).ToArray();
                }
                catch (Exception e)
                {
                    result = new object[] { e };
                }
            }

            if (notifyWildcard && s_Events.TryGetValue("*", out handlers))
            {
                try
                {
                    foreach (var handler in handlers)
                    {
                        handler(eventType, data);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }

            return(result);
        }
Example #13
0
        private async void Update()
        {
            while (!_cancelUpdateTokenSource.IsCancellationRequested)
            {
                if (!_client.Connected && LifeTimeMs - _lastReconnectionTimeSeconds > Config.ReconnectIntevalMs)
                {
                    _lastReconnectionTimeSeconds = LifeTimeMs;

                    try
                    {
                        Logger.LogWarning("Attempting reconnect");
                        await _client.ReconnectAsync(_cancelUpdateTokenSource);
                        await _handshake();
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                }

                if (!IsEstablished)
                {
                    continue;
                }

                try
                {
                    await ReadAsync();
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
        }
Example #14
0
        internal static void InitEntryPoint(Assembly assembly)
        {
            try
            {
                var version = RiderScriptEditorData.instance.editorBuildNumber;
                if (version != null)
                {
                    if (version.Major < 192)
                    {
                        DisableSyncSolutionOnceCallBack(); // is require for Rider prior to 2019.2
                    }
                }
                else
                {
                    DisableSyncSolutionOnceCallBack();
                }

                var type = assembly.GetType("JetBrains.Rider.Unity.Editor.AfterUnity56.EntryPoint");
                if (type == null)
                {
                    type = assembly.GetType("JetBrains.Rider.Unity.Editor.UnitTesting.EntryPoint"); // oldRider
                }
                RuntimeHelpers.RunClassConstructor(type.TypeHandle);
            }
            catch (TypeInitializationException ex)
            {
                Debug.LogException(ex);
                if (ex.InnerException != null)
                {
                    Debug.LogException(ex.InnerException);
                }
            }
        }
Example #15
0
        /// <summary>
        ///     Export received array of packages.
        /// </summary>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="ArgumentException"/>
        public static void ExportPackages([NotNull] string directory, [NotNull] JEMAssetBuilderPackage[] packages)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }
            if (packages == null)
            {
                throw new ArgumentNullException(nameof(packages));
            }
            if (packages.Length == 0)
            {
                throw new ArgumentException("Value cannot be an empty collection.", nameof(packages));
            }
            EditorUtility.DisplayProgressBar("JEM Asset Builder", "Starting up.", 0);

            try
            {
                var bundleBuildDirectory = JEMAssetsBuilderConfiguration.GetDirectory();
                var bundleBuildList      = new List <AssetBundleBuild>();
                for (var index = 0; index < packages.Length; index++)
                {
                    var package = packages[index];
                    EditorUtility.DisplayProgressBar("JEM Asset Builder", "Preparing to export: " + package.Name,
                                                     (float)index / packages.Length * 100f);

                    var filePath        = package.GetFile();
                    var fileName        = Path.GetFileName(filePath);
                    var bundleBuildData = new AssetBundleBuild
                    {
                        assetBundleName = fileName,
                        assetNames      = package.GetPathToAssets()
                    };

                    bundleBuildList.Add(bundleBuildData);
                }

                EditorUtility.DisplayProgressBar("JEM Asset Builder", "Starting Unity's AssetBundles building.", 0f);

                var manifest = BuildPipeline.BuildAssetBundles(bundleBuildDirectory, bundleBuildList.ToArray(), BundleOptions, BundleBuildTarget);
                if (manifest != null && manifest.GetAllAssetBundles().Length != 0)
                {
                    Debug.Log($"JEM Asset Builder successfully build {bundleBuildList.Count} packages!");

                    // Show target directory in File Explorer
                    Process.Start(bundleBuildDirectory);
                }
                else
                {
                    Debug.LogError($"JEM Asset Builder failed to build {bundleBuildList.Count} packages of Asset Bundles.");
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            EditorUtility.ClearProgressBar();
        }
Example #16
0
 public static void Exception(string tag, Exception exception)
 {
     if (!string.IsNullOrEmpty(tag) && !enabledTags.Contains(tag))
     {
         return;
     }
     Debug.LogException(exception);
 }
Example #17
0
 internal void PrintWarning(string formatString, params object[] formatArgs)
 {
     //Repl.StartWarnings();
     Debug.LogException(
         new PrologWarning(string.Format(formatString, formatArgs),
                           string.Format("{0} (at {1}:{2})\n", ISOPrologWriter.WriteToString(this.Head), this.SourceFile, this.SourceLineNumber))
         );
     //Console.Write(" in predicate {0}:{1}/{2}.", kb.Name, HeadFunctor, HeadArity);
 }
Example #18
0
 public void Debug(object message, Exception exception)
 {
     if (!IsDebugEnabled)
     {
         return;
     }
     Debugger.Log(Tag + message);
     Debugger.LogException(exception);
 }
Example #19
0
        protected override void Create(string path, string root, FilterMode mode)
        {
            if (!lfsManager.IsEnabled)
            {
                return;
            }
            try
            {
                var process   = new Process();
                var startInfo = new ProcessStartInfo
                {
                    FileName               = "git-lfs",
                    WorkingDirectory       = gitManager.RepoPath,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true,
                    UseShellExecute        = false
                };

                // launch git-lfs smudge or clean
                switch (mode)
                {
                case FilterMode.Smudge:
                    startInfo.Arguments = "smudge";
                    break;

                case FilterMode.Clean:
                    startInfo.Arguments = "clean";
                    break;

                default:
                    throw new ArgumentOutOfRangeException("mode");
                }

                process.StartInfo = startInfo;
                if (!process.Start())
                {
                    Debug.LogError("Cound not start lfs process of type: " + mode + " for path: " + path);
                }
                else
                {
                    if (processes.ContainsKey(path))
                    {
                        Debug.LogError("There is already lfs process for path: " + path);
                        return;
                    }
                    processes.Add(path, process);
                    modes.Add(path, mode);
                }
            }
            catch (Exception e)
            {
                Debug.LogError("LFS Create Error!");
                Debug.LogException(e);
            }
        }
Example #20
0
 public void Error(object message, Exception exception)
 {
     if (!IsErrorEnabled)
     {
         return;
     }
     Debugger.LogError(Tag + message);
     Debugger.LogException(exception);
 }
        private static void AdviseRunMethod(EditorPluginModel model)
        {
            model.RunMethodInUnity.Set((lifetime, data) =>
            {
                var task = new RdTask <RunMethodResult>();
                MainThreadDispatcher.Instance.Queue(() =>
                {
                    if (!lifetime.IsAlive)
                    {
                        task.SetCancelled();
                        return;
                    }

                    try
                    {
                        ourLogger.Verbose($"Attempt to execute {data.MethodName}");
                        var assemblies = AppDomain.CurrentDomain.GetAssemblies();
                        var assembly   = assemblies
                                         .FirstOrDefault(a => a.GetName().Name.Equals(data.AssemblyName));
                        if (assembly == null)
                        {
                            throw new Exception($"Could not find {data.AssemblyName} assembly in current AppDomain");
                        }

                        var type = assembly.GetType(data.TypeName);
                        if (type == null)
                        {
                            throw new Exception($"Could not find {data.TypeName} in assembly {data.AssemblyName}.");
                        }

                        var method = type.GetMethod(data.MethodName, BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

                        if (method == null)
                        {
                            throw new Exception($"Could not find {data.MethodName} in type {data.TypeName}");
                        }

                        try
                        {
                            method.Invoke(null, null);
                        }
                        catch (Exception e)
                        {
                            Debug.LogException(e);
                        }

                        task.Set(new RunMethodResult(true, string.Empty, string.Empty));
                    }
                    catch (Exception e)
                    {
                        ourLogger.Log(LoggingLevel.WARN, $"Execute {data.MethodName} failed.", e);
                        task.Set(new RunMethodResult(false, e.Message, e.StackTrace));
                    }
                });
                return(task);
            });
        }
Example #22
0
 public void Warn(object message, Exception exception)
 {
     if (!IsWarnEnabled)
     {
         return;
     }
     Debugger.LogWarning(Tag + message);
     Debugger.LogException(exception);
 }
 public static void TraceMethodCall()
 {
     try
     {
         throw new Exception("THIS EXCEPTION IS HARMLESS. TRACING METHOD CALL.");
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
Example #24
0
        public static bool OverrideFunction(IntPtr ptrOriginal, IntPtr ptrModified)
        {
            try
            {
                switch (IntPtr.Size)
                {
                case sizeof(Int32):
                    unsafe
                    {
                        byte *ptrFrom = (byte *)ptrOriginal.ToPointer();

                        *ptrFrom = 0x68;                                        // PUSH
                        *((uint *)(ptrFrom + 1)) = (uint)ptrModified.ToInt32(); // Pointer
                        *(ptrFrom + 5)           = 0xC3;                        // RETN

                        /* push, offset
                         * retn
                         *
                         *
                         */
                    }
                    break;

                case sizeof(Int64):
                    unsafe
                    {
                        byte *ptrFrom = (byte *)ptrOriginal.ToPointer();

                        *ptrFrom = 0x48;
                        *(ptrFrom + 1)            = 0xB8;
                        *((ulong *)(ptrFrom + 2)) = (ulong)ptrModified.ToInt64();                                // Pointer
                        *(ptrFrom + 10)           = 0xFF;
                        *(ptrFrom + 11)           = 0xE0;

                        /* mov rax, offset
                         * jmp rax
                         *
                         */
                    }
                    break;

                default:
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                return(false);
            }
        }
Example #25
0
        public static void Exception(Exception e)
        {
            if (IsTest)
            {
#if UNITY_STANDALONE && !UNITY_EDITOR
                DateTime now = DateTime.Now;
                builder.Append(string.Format("[{0} {1}] {2}{3}", now.ToShortDateString(), now.ToShortTimeString(), StringUtils.FlattenException(e), Environment.NewLine));
#else
                Debug.LogException(e);
#endif
            }
        }
Example #26
0
 public static void Main()
 {
     // Exception exception = null;
     try
     {
         new Program();
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
     }
 }
Example #27
0
        public UdpServerProxy(int port, Func <byte[], IPEndPoint, T> proccess)
        {
            var queue = new ConcurrentQueue <(byte[] buffer, IPEndPoint endPoint)>();
            var ip    = new IPEndPoint(IPAddress.Any, port);

            udpClient = new UdpClient(ip);

            Task.Run(() =>
            {
                using (udpClient)
                {
                    while (loopFlg)
                    {
                        try
                        {
                            var result = udpClient.ReceiveAsync();
                            if (result.Result.Buffer.Length > 0)
                            {
                                queue.Enqueue((result.Result.Buffer, result.Result.RemoteEndPoint));
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.LogException(e);
                        }
                    }
                }
            });

            subject = Observable
                      .Create <T>(observable =>
            {
                while (loopFlg)
                {
                    while (queue.TryDequeue(out var result))
                    {
                        var value = proccess(result.buffer, result.endPoint);
                        observable.OnNext(value);
                    }
                }
                observable.OnCompleted();
                return(Disposable.Empty);
            })
                      .SubscribeOn(Scheduler.ThreadPool)
                      .ObserveOnMainThread()
                      .Share();

            Observable
            .OnceApplicationQuit()
            .Subscribe(_ => Dispose());
        }
Example #28
0
 private static void Resolve(RequestData offer, object[] results)
 {
     for (int i = 0, end = offer.promises.Count; i != end; ++i)
     {
         try
         {
             offer.promises[i](null, results);
         }
         catch (Exception e)
         {
             Debug.LogException(e);
         }
     }
 }
Example #29
0
 private static void Reject(RequestData offer, Exception err)
 {
     for (int i = 0, end = offer.promises.Count; i != end; ++i)
     {
         try
         {
             offer.promises[i](err, null);
         }
         catch (Exception e)
         {
             Debug.LogException(e);
         }
     }
 }
Example #30
0
        /// <summary>
        /// Invokes the exception safe.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="args">The arguments.</param>
        public static void InvokeExceptionSafe(this object obj, string methodName, params object[] args)
        {
            try
            {
                obj.Invoke(methodName, args);
            }
            catch (Exception ex)
            {
#if !UNITY_2018 && !UNITY_2017 && !UNITY_5
                Console.WriteLine(ex, SysDrawing::System.Drawing.Color.Red);
#else
                Debug.LogException(ex);
#endif
            }
        }