Skip to content
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

Auto capture screenshots on failure Fixed #3928

Open
wants to merge 1 commit into
base: Releases/Official-Release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Ginger/GingerCoreCommon/Actions/Act.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public bool SupportSimulation
/// Gets a value indicating whether automatic screenshot capture is enabled on failure.
/// </summary>
private bool mAutoScreenShotOnFailure = true;
[IsSerializedForLocalRepository]
[IsSerializedForLocalRepository(DefaultValue:true)]
public bool AutoScreenShotOnFailure
{
get {
Expand All @@ -207,7 +207,6 @@ public bool AutoScreenShotOnFailure
}
}
}

public virtual eLocateBy LocateBy
{
get
Expand Down
5 changes: 5 additions & 0 deletions Ginger/GingerCoreCommon/Repository/RepositoryItemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ public bool CreateBackup(bool isLocalBackup = false)

return true;
}
catch (Exception ex)
{
Reporter.ToLog(eLogLevel.DEBUG, "Exception while creating backup", ex);
return false;
}
Comment on lines +345 to +349
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Exception handling added to CreateBackup method

The new code adds exception handling to the CreateBackup method. This is a good practice as it prevents unhandled exceptions from propagating and potentially crashing the application.

However, there are a few points to consider:

  1. The exception is only logged at DEBUG level, which might not be sufficient for critical errors.
  2. The method returns false on exception, but there's no way for the caller to know if it failed due to an exception or for another reason.

Consider the following improvements:

  1. Log the exception at ERROR level instead of DEBUG.
  2. Create an enum or use out parameter to provide more detailed error information to the caller.

Here's a suggested implementation:

- catch (Exception ex)
- {
-     Reporter.ToLog(eLogLevel.DEBUG, "Exception while creating backup", ex);
-     return false;
- }
+ catch (Exception ex)
+ {
+     Reporter.ToLog(eLogLevel.ERROR, "Exception while creating backup", ex);
+     return false;
+ }

Committable suggestion was skipped due to low confidence.

finally
{
mBackupInProgress = false;
Expand Down
Loading