-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix various C# exceptions #64900
Fix various C# exceptions #64900
Conversation
modules/mono/editor/GodotTools/GodotTools.IdeMessaging/Utils/NotifyAwaiter.cs
Outdated
Show resolved
Hide resolved
Is
https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception?view=net-6.0#Throwing |
I'm not sure but I can't think of a better exception. Even if it's not related to the object's state it's somewhat related to the state of the project as a whole (for example if the build/publish process fails) so maybe it's ok, otherwise we may consider implementing our own exceptions for these cases (see https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2201). |
b1e8737
to
0610bce
Compare
modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs
Outdated
Show resolved
Hide resolved
modules/mono/editor/GodotTools/GodotTools/Export/XcodeHelper.cs
Outdated
Show resolved
Hide resolved
We could always change those |
0610bce
to
f069ae4
Compare
- Replace `IndexOutOfRangeException` with `ArgumentOutOfRangeException` - Replace `Exception` with a more specific exception - Add the parameter name to argument exception - Update documentation for methods that throw exceptions - Use `StringBuilder` to build exception messages - Ensure exception messages end with a period
f069ae4
to
79f9f59
Compare
@@ -293,15 +293,15 @@ private void ScrollToLastNonEmptyLogLine() | |||
public void RestartBuild() | |||
{ | |||
if (!HasBuildExited) | |||
throw new InvalidOperationException("Build already started"); | |||
throw new InvalidOperationException("Build already started."); | |||
|
|||
BuildManager.RestartBuild(this); | |||
} | |||
|
|||
public void StopBuild() | |||
{ | |||
if (!HasBuildExited) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm new to this but shouldn't this be HasBuildExited
instead of !HasBuildExited
? Won't an in-progress build have this value as false?
I'm just trying to understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, but looking a bit more into this it seems these RestartBuild
and StopBuild
methods are not used and the BuildManager
methods they call throw a NotImplementedException
. It seems they were never really used, since the rebuild and stop buttons are implemented in MSPanel
(previously named BottomPanel
).
Also, building is always a blocking operation so these methods would never be executed if a build is in-progress anyway although we do want to support building in the background (see godotengine/godot-proposals#849 (comment)), it's just not implemented yet.
IndexOutOfRangeException
withArgumentOutOfRangeException
.Exception
with a more specific exception.StringBuilder
to build exception messages.I couldn't think of a better exception than
InvalidOperationException
to replaceException
but I'm not sure it's the best option in all cases.