Skip to content

Commit

Permalink
Merge pull request #103 from nowsprinting/feature/error_handler_agent
Browse files Browse the repository at this point in the history
Add ErrorHandlerAgent migrated from LogMessageHandler
  • Loading branch information
asurato authored Nov 11, 2024
2 parents 4f1f4ff + dbfb94d commit 9c26535
Show file tree
Hide file tree
Showing 29 changed files with 1,060 additions and 577 deletions.
88 changes: 44 additions & 44 deletions Editor/Localization/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -103,50 +103,6 @@ msgstr "Reporters"
msgid "List of Reporters to be called on Autopilot terminate."
msgstr "オートパイロット終了時に通知を行なうReporterを指定します"

# Header: Error Handling Settings
msgid "Error Handling Settings"
msgstr "エラーハンドリング設定"

# handleException
msgid "Handle Exception"
msgstr "例外を報告する"

# handleException tooltip
msgid "Notify when Exception detected in log"
msgstr "例外ログを検知したらSlack通知します"

# handleError
msgid "Handle Error"
msgstr "エラーを報告する"

# handleError tooltip
msgid "Notify when Error detected in log"
msgstr "エラーログを検知したらSlack通知します"

# handleAssert
msgid "Handle Assert"
msgstr "アサートを報告する"

# handleAssert tooltip
msgid "Notify when Assert detected in log"
msgstr "アサートログを検知したらSlack通知します"

# handleWarning
msgid "Handle Warning"
msgstr "警告を報告する"

# handleWarning tooltip
msgid "Notify when Warning detected in log"
msgstr "警告ログを検知したらSlack通知します"

# ignoreMessages
msgid "Ignore Messages"
msgstr "無視するメッセージ"

# ignoreMessages tooltip
msgid "Do not send notifications when log messages contain this string"
msgstr "ログメッセージの中にこの文字列が含まれていたらSlack通知を行ないません"

# Autopilot実行ボタン
msgid "Run"
msgstr "実行"
Expand Down Expand Up @@ -384,6 +340,7 @@ msgstr "ステレオキャプチャモード"
msgid "The eye texture to capture when stereo rendering is enabled. Neither this nor Resolution Factor can be specified"
msgstr "ステレオレンダリングが有効な場合にどちらのカメラを使用するかを指定できます。拡大係数と同時には設定できません"


#: Editor/UI/Agents/UGUIPlaybackAgentEditor.cs

# recordedJson
Expand All @@ -395,6 +352,49 @@ msgid "JSON file recorded by AutomatedQA package"
msgstr "Automated QAパッケージのRecorded Playbackウィンドウで記録したjsonファイルを設定します"


#: Editor/UI/Agents/ErrorHandlerAgent.cs

# handleException
msgid "Handle Exception"
msgstr "例外を捕捉"

# handleException tooltip
msgid "Specify an Autopilot terminates or only reports when an Exception is detected in the log"
msgstr "例外ログを検知したとき、オートパイロットを停止するか、レポート送信のみ行なうかを指定します"

# handleError
msgid "Handle Error"
msgstr "エラーを検知"

# handleError tooltip
msgid "Specify an Autopilot terminates or only reports when an Error is detected in the log"
msgstr "エラーログを検知したとき、オートパイロットを停止するか、レポート送信のみ行なうかを指定します"

# handleAssert
msgid "Handle Assert"
msgstr "アサートを検知"

# handleAssert tooltip
msgid "Specify an Autopilot terminates or only reports when an Assert is detected in the log"
msgstr "アサートログを検知したとき、オートパイロットを停止するか、レポート送信のみ行なうかを指定します"

# handleWarning
msgid "Handle Warning"
msgstr "警告を検知"

# handleWarning tooltip
msgid "Specify an Autopilot terminates or only reports when an Warning is detected in the log"
msgstr "警告ログを検知したとき、オートパイロットを停止するか、レポート送信のみ行なうかを指定します"

# ignoreMessages
msgid "Ignore Messages"
msgstr "無視するメッセージ"

# ignoreMessages tooltip
msgid "Log messages containing the specified strings will be ignored from the stop condition. Regex is also available; escape is a single backslash (\)."
msgstr "指定された文字列を含むログメッセージは停止条件から無視されます。正規表現も使用できます。エスケープは単一のバックスラッシュ (\) です"


#: Editor/UI/Loggers/ 共通

# description (same as AutopilotSettingsEditor.cs)
Expand Down
95 changes: 95 additions & 0 deletions Editor/UI/Agents/ErrorHandlerAgentEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright (c) 2023-2024 DeNA Co., Ltd.
// This software is released under the MIT License.

using DeNA.Anjin.Agents;
using UnityEditor;
using UnityEngine;

namespace DeNA.Anjin.Editor.UI.Agents
{
/// <summary>
/// Editor GUI for ErrorHandlerAgent
/// </summary>
[CustomEditor(typeof(ErrorHandlerAgent))]
public class ErrorHandlerAgentEditor : UnityEditor.Editor
{
private const float SpacerPixels = 10f;

// @formatter:off
private static readonly string s_description = L10n.Tr("Description");
private static readonly string s_descriptionTooltip = L10n.Tr("Description about this Agent instance");
private SerializedProperty _descriptionProp;
private GUIContent _descriptionLabel;

private static readonly string s_handleException = L10n.Tr("Handle Exception");
private static readonly string s_handleExceptionTooltip = L10n.Tr("Specify an Autopilot terminates or only reports when an Exception is detected in the log");
private SerializedProperty _handleExceptionProp;
private GUIContent _handleExceptionLabel;

private static readonly string s_handleError = L10n.Tr("Handle Error");
private static readonly string s_handleErrorTooltip = L10n.Tr("Specify an Autopilot terminates or only reports when an Error is detected in the log");
private SerializedProperty _handleErrorProp;
private GUIContent _handleErrorLabel;

private static readonly string s_handleAssert = L10n.Tr("Handle Assert");
private static readonly string s_handleAssertTooltip = L10n.Tr("Specify an Autopilot terminates or only reports when an Assert is detected in the log");
private SerializedProperty _handleAssertProp;
private GUIContent _handleAssertLabel;

private static readonly string s_handleWarning = L10n.Tr("Handle Warning");
private static readonly string s_handleWarningTooltip = L10n.Tr("Specify an Autopilot terminates or only reports when an Warning is detected in the log");
private SerializedProperty _handleWarningProp;
private GUIContent _handleWarningLabel;

private static readonly string s_ignoreMessages = L10n.Tr("Ignore Messages");
private static readonly string s_ignoreMessagesTooltip = L10n.Tr("Log messages containing the specified strings will be ignored from the stop condition. Regex is also available; escape is a single backslash (\\).");
private SerializedProperty _ignoreMessagesProp;
private GUIContent _ignoreMessagesLabel;
// @formatter:on

private void OnEnable()
{
Initialize();
}

private void Initialize()
{
_descriptionProp = serializedObject.FindProperty(nameof(ErrorHandlerAgent.description));
_descriptionLabel = new GUIContent(s_description, s_descriptionTooltip);

_handleExceptionProp = serializedObject.FindProperty(nameof(ErrorHandlerAgent.handleException));
_handleExceptionLabel = new GUIContent(s_handleException, s_handleExceptionTooltip);

_handleErrorProp = serializedObject.FindProperty(nameof(ErrorHandlerAgent.handleError));
_handleErrorLabel = new GUIContent(s_handleError, s_handleErrorTooltip);

_handleAssertProp = serializedObject.FindProperty(nameof(ErrorHandlerAgent.handleAssert));
_handleAssertLabel = new GUIContent(s_handleAssert, s_handleAssertTooltip);

_handleWarningProp = serializedObject.FindProperty(nameof(ErrorHandlerAgent.handleWarning));
_handleWarningLabel = new GUIContent(s_handleWarning, s_handleWarningTooltip);

_ignoreMessagesProp = serializedObject.FindProperty(nameof(ErrorHandlerAgent.ignoreMessages));
_ignoreMessagesLabel = new GUIContent(s_ignoreMessages, s_ignoreMessagesTooltip);
}

/// <inheritdoc/>
public override void OnInspectorGUI()
{
serializedObject.Update();

EditorGUILayout.PropertyField(_descriptionProp, _descriptionLabel);
GUILayout.Space(SpacerPixels);

EditorGUILayout.PropertyField(_handleExceptionProp, _handleExceptionLabel);
EditorGUILayout.PropertyField(_handleErrorProp, _handleErrorLabel);
EditorGUILayout.PropertyField(_handleAssertProp, _handleAssertLabel);
EditorGUILayout.PropertyField(_handleWarningProp, _handleWarningLabel);
GUILayout.Space(SpacerPixels);

EditorGUILayout.PropertyField(_ignoreMessagesProp, _ignoreMessagesLabel);

serializedObject.ApplyModifiedProperties();
}
}
}
3 changes: 3 additions & 0 deletions Editor/UI/Agents/ErrorHandlerAgentEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 1 addition & 29 deletions Editor/UI/Settings/AutopilotSettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ public class AutopilotSettingsEditor : UnityEditor.Editor
private static readonly string s_reporters = L10n.Tr("Reporters");
private static readonly string s_reportersTooltip = L10n.Tr("List of Reporters to be called on Autopilot terminate.");

private static readonly string s_errorHandlingSettingsHeader = L10n.Tr("Error Handling Settings");
private static readonly string s_handleException = L10n.Tr("Handle Exception");
private static readonly string s_handleExceptionTooltip = L10n.Tr("Notify when Exception detected in log");
private static readonly string s_handleError = L10n.Tr("Handle Error");
private static readonly string s_handleErrorTooltip = L10n.Tr("Notify when Error detected in log");
private static readonly string s_handleAssert = L10n.Tr("Handle Assert");
private static readonly string s_handleAssertTooltip = L10n.Tr("Notify when Assert detected in log");
private static readonly string s_handleWarning = L10n.Tr("Handle Warning");
private static readonly string s_handleWarningTooltip = L10n.Tr("Notify when Warning detected in log");
private static readonly string s_ignoreMessages = L10n.Tr("Ignore Messages");
private static readonly string s_ignoreMessagesTooltip = L10n.Tr("Do not send notifications when log messages contain this string");

private static readonly string s_runButton = L10n.Tr("Run");
private static readonly string s_stopButton = L10n.Tr("Stop");
private const float SpacerPixels = 10f;
Expand Down Expand Up @@ -93,18 +81,6 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.reporters)),
new GUIContent(s_reporters, s_reportersTooltip));

DrawHeader(s_errorHandlingSettingsHeader);
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.handleException)),
new GUIContent(s_handleException, s_handleExceptionTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.handleError)),
new GUIContent(s_handleError, s_handleErrorTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.handleAssert)),
new GUIContent(s_handleAssert, s_handleAssertTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.handleWarning)),
new GUIContent(s_handleWarning, s_handleWarningTooltip));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(AutopilotSettings.ignoreMessages)),
new GUIContent(s_ignoreMessages, s_ignoreMessagesTooltip), true);

serializedObject.ApplyModifiedProperties();

GUILayout.Space(SpacerPixels);
Expand Down Expand Up @@ -136,11 +112,7 @@ private static void DrawHeader(string label)
// ReSharper disable once MemberCanBeMadeStatic.Global
internal void Stop()
{
var autopilot = FindObjectOfType<Autopilot>();
if (autopilot)
{
autopilot.TerminateAsync(ExitCode.Normally, reporting: false).Forget();
}
Autopilot.Instance.TerminateAsync(ExitCode.Normally, reporting: false).Forget();
}

internal void Launch()
Expand Down
Loading

0 comments on commit 9c26535

Please sign in to comment.