diff --git a/Source/Editor/Editor.cs b/Source/Editor/Editor.cs index d4afdd693..50de80e88 100644 --- a/Source/Editor/Editor.cs +++ b/Source/Editor/Editor.cs @@ -891,10 +891,10 @@ namespace FlaxEditor if (asset == null) throw new ArgumentNullException(nameof(asset)); if (asset.WaitForLoaded()) - throw new FlaxException("Failed to load asset."); + throw new Exception("Failed to load asset."); var source = Internal_GetShaderAssetSourceCode(FlaxEngine.Object.GetUnmanagedPtr(asset)); if (source == null) - throw new FlaxException("Failed to get source code."); + throw new Exception("Failed to get source code."); return source; } diff --git a/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs b/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs index 96e858a9a..b5026b1b1 100644 --- a/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/CameraCutTrack.cs @@ -631,7 +631,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks } } if (spriteIndex == -1) - throw new FlaxException(); + throw new Exception(); atlas.Count++; _atlases[atlasIndex] = atlas; var sprite = new SpriteHandle(atlas.Texture, spriteIndex); diff --git a/Source/Editor/Modules/PrefabsModule.cs b/Source/Editor/Modules/PrefabsModule.cs index 94ae8d736..71531df2d 100644 --- a/Source/Editor/Modules/PrefabsModule.cs +++ b/Source/Editor/Modules/PrefabsModule.cs @@ -212,7 +212,7 @@ namespace FlaxEditor.Modules // Call backend if (PrefabManager.Internal_ApplyAll(FlaxEngine.Object.GetUnmanagedPtr(instance))) - throw new FlaxException("Failed to apply the prefab. See log to learn more."); + throw new Exception("Failed to apply the prefab. See log to learn more."); PrefabApplied?.Invoke(prefab, instance); } diff --git a/Source/Editor/Tools/Terrain/Paint/Mode.cs b/Source/Editor/Tools/Terrain/Paint/Mode.cs index 23b3d47f1..e0eea6186 100644 --- a/Source/Editor/Tools/Terrain/Paint/Mode.cs +++ b/Source/Editor/Tools/Terrain/Paint/Mode.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. +using System; using FlaxEditor.Tools.Terrain.Brushes; using FlaxEngine; @@ -129,9 +130,7 @@ namespace FlaxEditor.Tools.Terrain.Paint // Get the patch data (cached internally by the c++ core in editor) var sourceData = TerrainTools.GetSplatMapData(terrain, ref patch.PatchCoord, splatmapIndex); if (sourceData == null) - { - throw new FlaxException("Cannot modify terrain. Loading splatmap failed. See log for more info."); - } + throw new Exception("Cannot modify terrain. Loading splatmap failed. See log for more info."); // Record patch data before editing it if (!gizmo.CurrentEditUndoAction.HashPatch(ref patch.PatchCoord)) diff --git a/Source/Editor/Tools/Terrain/Sculpt/Mode.cs b/Source/Editor/Tools/Terrain/Sculpt/Mode.cs index 0708a2558..1e1ece566 100644 --- a/Source/Editor/Tools/Terrain/Sculpt/Mode.cs +++ b/Source/Editor/Tools/Terrain/Sculpt/Mode.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. +using System; using FlaxEditor.Tools.Terrain.Brushes; using FlaxEngine; @@ -128,9 +129,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt float* sourceHeights = EditHoles ? null : TerrainTools.GetHeightmapData(terrain, ref patch.PatchCoord); byte* sourceHoles = EditHoles ? TerrainTools.GetHolesMaskData(terrain, ref patch.PatchCoord) : null; if (sourceHeights == null && sourceHoles == null) - { - throw new FlaxException("Cannot modify terrain. Loading heightmap failed. See log for more info."); - } + throw new Exception("Cannot modify terrain. Loading heightmap failed. See log for more info."); // Record patch data before editing it if (!gizmo.CurrentEditUndoAction.HashPatch(ref patch.PatchCoord)) diff --git a/Source/Editor/Tools/Terrain/Undo/EditTerrainHeightMapAction.cs b/Source/Editor/Tools/Terrain/Undo/EditTerrainHeightMapAction.cs index 833e2b8e9..252263902 100644 --- a/Source/Editor/Tools/Terrain/Undo/EditTerrainHeightMapAction.cs +++ b/Source/Editor/Tools/Terrain/Undo/EditTerrainHeightMapAction.cs @@ -37,7 +37,7 @@ namespace FlaxEditor.Tools.Terrain.Undo var offset = Int2.Zero; var size = new Int2((int)Mathf.Sqrt(_heightmapLength)); if (TerrainTools.ModifyHeightMap(Terrain, ref patchCoord, (float*)data, ref offset, ref size)) - throw new FlaxException("Failed to modify the heightmap."); + throw new Exception("Failed to modify the heightmap."); } } } diff --git a/Source/Editor/Tools/Terrain/Undo/EditTerrainHolesMapAction.cs b/Source/Editor/Tools/Terrain/Undo/EditTerrainHolesMapAction.cs index 9f81f14ba..d8ebe425d 100644 --- a/Source/Editor/Tools/Terrain/Undo/EditTerrainHolesMapAction.cs +++ b/Source/Editor/Tools/Terrain/Undo/EditTerrainHolesMapAction.cs @@ -37,7 +37,7 @@ namespace FlaxEditor.Tools.Terrain.Undo var offset = Int2.Zero; var size = new Int2((int)Mathf.Sqrt(_heightmapLength)); if (TerrainTools.ModifyHolesMask(Terrain, ref patchCoord, (byte*)data, ref offset, ref size)) - throw new FlaxException("Failed to modify the terrain holes."); + throw new Exception("Failed to modify the terrain holes."); } } } diff --git a/Source/Editor/Tools/Terrain/Undo/EditTerrainSplatMapAction.cs b/Source/Editor/Tools/Terrain/Undo/EditTerrainSplatMapAction.cs index b4b1d3e97..dfe6e553d 100644 --- a/Source/Editor/Tools/Terrain/Undo/EditTerrainSplatMapAction.cs +++ b/Source/Editor/Tools/Terrain/Undo/EditTerrainSplatMapAction.cs @@ -37,7 +37,7 @@ namespace FlaxEditor.Tools.Terrain.Undo var offset = Int2.Zero; var size = new Int2((int)Mathf.Sqrt(_heightmapLength)); if (TerrainTools.ModifySplatMap(Terrain, ref patchCoord, (int)tag, (Color32*)data, ref offset, ref size)) - throw new FlaxException("Failed to modify the splatmap."); + throw new Exception("Failed to modify the splatmap."); } } } diff --git a/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs b/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs index a471c166b..d2db66792 100644 --- a/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs +++ b/Source/Editor/Undo/Actions/BreakPrefabLinkAction.cs @@ -68,7 +68,7 @@ namespace FlaxEditor.Actions if (actor == null) throw new ArgumentNullException(nameof(actor)); if (!actor.HasPrefabLink) - throw new FlaxException("Cannot register missing prefab link."); + throw new Exception("Cannot register missing prefab link."); return new BreakPrefabLinkAction(false, actor); } @@ -102,11 +102,11 @@ namespace FlaxEditor.Actions private void DoLink() { if (_prefabObjectIds == null) - throw new FlaxException("Cannot link prefab. Missing objects Ids mapping."); + throw new Exception("Cannot link prefab. Missing objects Ids mapping."); var actor = Object.Find(ref _actorId); if (actor == null) - throw new FlaxException("Cannot link prefab. Missing actor."); + throw new Exception("Cannot link prefab. Missing actor."); // Restore cached links foreach (var e in _prefabObjectIds) @@ -149,9 +149,9 @@ namespace FlaxEditor.Actions { var actor = Object.Find(ref _actorId); if (actor == null) - throw new FlaxException("Cannot break prefab link. Missing actor."); + throw new Exception("Cannot break prefab link. Missing actor."); if (!actor.HasPrefabLink) - throw new FlaxException("Cannot break missing prefab link."); + throw new Exception("Cannot break missing prefab link."); if (_prefabObjectIds == null) _prefabObjectIds = new Dictionary(1024); diff --git a/Source/Editor/Utilities/DuplicateScenes.cs b/Source/Editor/Utilities/DuplicateScenes.cs index 87a375e1b..e9ff1b6f9 100644 --- a/Source/Editor/Utilities/DuplicateScenes.cs +++ b/Source/Editor/Utilities/DuplicateScenes.cs @@ -72,7 +72,7 @@ namespace FlaxEditor.Utilities if (Level.UnloadAllScenes()) { Profiler.EndEvent(); - throw new FlaxException("Failed to unload scenes."); + throw new Exception("Failed to unload scenes."); } FlaxEngine.Scripting.FlushRemovedObjects(); @@ -82,7 +82,7 @@ namespace FlaxEditor.Utilities if (noScenes != null && noScenes.Length != 0) { Profiler.EndEvent(); - throw new FlaxException("Failed to unload scenes."); + throw new Exception("Failed to unload scenes."); } } @@ -110,7 +110,7 @@ namespace FlaxEditor.Utilities if (scene == null) { Profiler.EndEvent(); - throw new FlaxException("Failed to deserialize scene"); + throw new Exception("Failed to deserialize scene"); } } @@ -131,7 +131,7 @@ namespace FlaxEditor.Utilities if (Level.UnloadAllScenes()) { Profiler.EndEvent(); - throw new FlaxException("Failed to unload scenes."); + throw new Exception("Failed to unload scenes."); } FlaxEngine.Scripting.FlushRemovedObjects(); Profiler.EndEvent(); @@ -154,7 +154,7 @@ namespace FlaxEditor.Utilities if (scene == null) { Profiler.EndEvent(); - throw new FlaxException("Failed to deserialize scene"); + throw new Exception("Failed to deserialize scene"); } // Restore `dirty` state diff --git a/Source/Editor/Viewport/Previews/IESProfilePreview.cs b/Source/Editor/Viewport/Previews/IESProfilePreview.cs index 9ed66c1bf..aaec77bc6 100644 --- a/Source/Editor/Viewport/Previews/IESProfilePreview.cs +++ b/Source/Editor/Viewport/Previews/IESProfilePreview.cs @@ -1,6 +1,8 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. +using System; using FlaxEngine; +using Object = FlaxEngine.Object; namespace FlaxEditor.Viewport.Previews { @@ -39,7 +41,7 @@ namespace FlaxEditor.Viewport.Previews // Wait for base (don't want to async material parameters set due to async loading) if (baseMaterial == null || baseMaterial.WaitForLoaded()) - throw new FlaxException("Cannot load IES Profile preview material."); + throw new Exception("Cannot load IES Profile preview material."); // Create preview material (virtual) _previewMaterial = baseMaterial.CreateVirtualInstance(); diff --git a/Source/Editor/Viewport/Previews/PrefabPreview.cs b/Source/Editor/Viewport/Previews/PrefabPreview.cs index c5ad97455..7f908c141 100644 --- a/Source/Editor/Viewport/Previews/PrefabPreview.cs +++ b/Source/Editor/Viewport/Previews/PrefabPreview.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. +using System; using FlaxEngine; using Object = FlaxEngine.Object; @@ -54,7 +55,7 @@ namespace FlaxEditor.Viewport.Previews if (instance == null) { _prefab = null; - throw new FlaxException("Failed to spawn a prefab for the preview."); + throw new Exception("Failed to spawn a prefab for the preview."); } // Set instance diff --git a/Source/Editor/Viewport/Previews/TexturePreview.cs b/Source/Editor/Viewport/Previews/TexturePreview.cs index 278fd6c2b..09e7016e5 100644 --- a/Source/Editor/Viewport/Previews/TexturePreview.cs +++ b/Source/Editor/Viewport/Previews/TexturePreview.cs @@ -319,10 +319,10 @@ namespace FlaxEditor.Viewport.Previews // Create preview material (virtual) var baseMaterial = FlaxEngine.Content.LoadAsyncInternal("Editor/TexturePreviewMaterial"); if (baseMaterial == null) - throw new FlaxException("Cannot load texture preview material."); + throw new Exception("Cannot load texture preview material."); _previewMaterial = baseMaterial.CreateVirtualInstance(); if (_previewMaterial == null) - throw new FlaxException("Failed to create virtual material instance for preview material."); + throw new Exception("Failed to create virtual material instance for preview material."); // Add widgets if (useWidgets) diff --git a/Source/Engine/Engine/FlaxException.cs b/Source/Engine/Engine/FlaxException.cs deleted file mode 100644 index 147b00c4c..000000000 --- a/Source/Engine/Engine/FlaxException.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. - -using System; - -namespace FlaxEngine -{ - /// - /// Flax exception object. - /// - /// - [Serializable] - public class FlaxException : SystemException - { - /// - /// Initializes a new instance of the class. - /// - public FlaxException() - : base("A Flax runtime error occurred!") - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The message that describes the error. - public FlaxException(string message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The error message that explains the reason for the exception. - /// The exception that is the cause of the current exception. If the parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception. - public FlaxException(string message, Exception innerException) - : base(message, innerException) - { - } - } -} diff --git a/Source/Engine/Graphics/Mesh.cs b/Source/Engine/Graphics/Mesh.cs index 2cdcc73b1..25129137c 100644 --- a/Source/Engine/Graphics/Mesh.cs +++ b/Source/Engine/Graphics/Mesh.cs @@ -154,7 +154,7 @@ namespace FlaxEngine uv, colors )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -201,7 +201,7 @@ namespace FlaxEngine Utils.ExtractArrayFromList(uv), Utils.ExtractArrayFromList(colors) )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -247,7 +247,7 @@ namespace FlaxEngine uv, colors )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -294,7 +294,7 @@ namespace FlaxEngine Utils.ExtractArrayFromList(uv), Utils.ExtractArrayFromList(colors) )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -341,7 +341,7 @@ namespace FlaxEngine uv, colors )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -388,7 +388,7 @@ namespace FlaxEngine Utils.ExtractArrayFromList(uv), Utils.ExtractArrayFromList(colors) )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -412,7 +412,7 @@ namespace FlaxEngine triangles.Length / 3, triangles )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -436,7 +436,7 @@ namespace FlaxEngine triangles.Count / 3, Utils.ExtractArrayFromList(triangles) )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -460,7 +460,7 @@ namespace FlaxEngine triangles.Length / 3, triangles )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -484,7 +484,7 @@ namespace FlaxEngine triangles.Count / 3, Utils.ExtractArrayFromList(triangles) )) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } internal enum InternalBufferType @@ -506,7 +506,7 @@ namespace FlaxEngine var vertices = VertexCount; var result = new Vertex0[vertices]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.VB0)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } @@ -520,7 +520,7 @@ namespace FlaxEngine var vertices = VertexCount; var result = new Vertex1[vertices]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.VB1)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } @@ -540,7 +540,7 @@ namespace FlaxEngine var vertices = VertexCount; var result = new Vertex2[vertices]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.VB2)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } @@ -597,7 +597,7 @@ namespace FlaxEngine var triangles = TriangleCount; var result = new uint[triangles * 3]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.IB32)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } @@ -612,7 +612,7 @@ namespace FlaxEngine var triangles = TriangleCount; var result = new ushort[triangles * 3]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.IB16)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } } diff --git a/Source/Engine/Graphics/SkinnedMesh.cs b/Source/Engine/Graphics/SkinnedMesh.cs index d59f619a7..5ccb25e46 100644 --- a/Source/Engine/Graphics/SkinnedMesh.cs +++ b/Source/Engine/Graphics/SkinnedMesh.cs @@ -131,7 +131,7 @@ namespace FlaxEngine throw new ArgumentOutOfRangeException(nameof(uv)); if (Internal_UpdateMeshUInt(__unmanagedPtr, vertices, triangles, blendIndices, blendWeights, normals, tangents, uv)) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -167,7 +167,7 @@ namespace FlaxEngine throw new ArgumentOutOfRangeException(nameof(uv)); if (Internal_UpdateMeshUInt(__unmanagedPtr, vertices, triangles, blendIndices, blendWeights, normals, tangents, uv)) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } /// @@ -203,7 +203,7 @@ namespace FlaxEngine throw new ArgumentOutOfRangeException(nameof(uv)); if (Internal_UpdateMeshUShort(__unmanagedPtr, vertices, triangles, blendIndices, blendWeights, normals, tangents, uv)) - throw new FlaxException("Failed to update mesh data."); + throw new Exception("Failed to update mesh data."); } internal enum InternalBufferType @@ -223,7 +223,7 @@ namespace FlaxEngine var vertices = VertexCount; var result = new Vertex0[vertices]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.VB0)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } @@ -268,7 +268,7 @@ namespace FlaxEngine var triangles = TriangleCount; var result = new uint[triangles * 3]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.IB32)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } @@ -283,7 +283,7 @@ namespace FlaxEngine var triangles = TriangleCount; var result = new ushort[triangles * 3]; if (Internal_DownloadBuffer(__unmanagedPtr, forceGpu, result, (int)InternalBufferType.IB16)) - throw new FlaxException("Failed to download mesh data."); + throw new Exception("Failed to download mesh data."); return result; } } diff --git a/Source/Engine/Graphics/TextureBase.cs b/Source/Engine/Graphics/TextureBase.cs index 63f17cc09..19ae402d7 100644 --- a/Source/Engine/Graphics/TextureBase.cs +++ b/Source/Engine/Graphics/TextureBase.cs @@ -177,7 +177,7 @@ namespace FlaxEngine // Call backend if (Internal_Init(__unmanagedPtr, new IntPtr(&t))) - throw new FlaxException("Failed to init texture data."); + throw new Exception("Failed to init texture data."); } } diff --git a/Source/Engine/Scripting/Object.cs b/Source/Engine/Scripting/Object.cs index 51001a86a..b86ed00d8 100644 --- a/Source/Engine/Scripting/Object.cs +++ b/Source/Engine/Scripting/Object.cs @@ -47,7 +47,7 @@ namespace FlaxEngine { Internal_ManagedInstanceCreated(this); if (__unmanagedPtr == IntPtr.Zero) - throw new FlaxException($"Failed to create native instance for object of type {GetType().FullName} (assembly: {GetType().Assembly.FullName})."); + throw new Exception($"Failed to create native instance for object of type {GetType().FullName} (assembly: {GetType().Assembly.FullName})."); } } diff --git a/Source/Engine/Serialization/JsonSerializer.cs b/Source/Engine/Serialization/JsonSerializer.cs index 2099bc387..29a5951f9 100644 --- a/Source/Engine/Serialization/JsonSerializer.cs +++ b/Source/Engine/Serialization/JsonSerializer.cs @@ -188,7 +188,7 @@ namespace FlaxEngine.Json while (reader.Read()) { if (reader.TokenType != JsonToken.Comment) - throw new FlaxException("Additional text found in JSON string after finishing deserializing object."); + throw new Exception("Additional text found in JSON string after finishing deserializing object."); } } } @@ -226,7 +226,7 @@ namespace FlaxEngine.Json while (reader.Read()) { if (reader.TokenType != JsonToken.Comment) - throw new FlaxException("Additional text found in JSON string after finishing deserializing object."); + throw new Exception("Additional text found in JSON string after finishing deserializing object."); } } @@ -254,7 +254,7 @@ namespace FlaxEngine.Json while (reader.Read()) { if (reader.TokenType != JsonToken.Comment) - throw new FlaxException("Additional text found in JSON string after finishing deserializing object."); + throw new Exception("Additional text found in JSON string after finishing deserializing object."); } } @@ -297,7 +297,7 @@ namespace FlaxEngine.Json while (jsonReader.Read()) { if (jsonReader.TokenType != JsonToken.Comment) - throw new FlaxException("Additional text found in JSON string after finishing deserializing object."); + throw new Exception("Additional text found in JSON string after finishing deserializing object."); } }