Skip to content

Commit

Permalink
refactor: 🧑‍💻 move error prefix to const string (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNZL committed Jul 7, 2023
1 parent 3a97862 commit fba057a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Settings
internal const string ResumeFlag = $"{Settings.FlagPrefix}R";
internal const string ShowStopFlag = $"{Settings.FlagPrefix}S";

internal const string ErrorPrefix = "ERROR: ";
internal const string NoProjectName = "No Project";
internal const string NoClientName = "No Client";
internal const string EmptyDescription = "(no description)";
Expand Down
14 changes: 7 additions & 7 deletions src/TogglTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ internal List<Result> NotifyMissingToken()
{
new Result
{
Title = "ERROR: Missing API token",
Title = $"{Settings.ErrorPrefix}Missing API token",
SubTitle = "Configure Toggl Track API token in Flow Launcher settings.",
IcoPath = "tip-error.png",
Action = _ =>
Expand Down Expand Up @@ -519,7 +519,7 @@ internal List<Result> NotifyNetworkUnavailable()
{
new Result
{
Title = "ERROR: No network connection",
Title = $"{Settings.ErrorPrefix}No network connection",
SubTitle = "Connect to the internet to use Toggl Track.",
IcoPath = "tip-error.png",
Action = _ =>
Expand All @@ -536,7 +536,7 @@ internal List<Result> NotifyInvalidToken()
{
new Result
{
Title = "ERROR: Invalid API token",
Title = $"{Settings.ErrorPrefix}Invalid API token",
SubTitle = $"{this._settings.ApiToken} is not a valid API token.",
IcoPath = "tip-error.png",
Action = _ =>
Expand Down Expand Up @@ -565,7 +565,7 @@ internal List<Result> NotifyUnknownError()
{
new Result
{
Title = "ERROR: Unknown error",
Title = $"{Settings.ErrorPrefix}Unknown error",
SubTitle = "An unexpected error has occurred.",
IcoPath = "tip-error.png",
Action = _ =>
Expand Down Expand Up @@ -2073,7 +2073,7 @@ private async ValueTask<List<Result>> _GetEditResults(CancellationToken token, Q

results.Add(new Result
{
Title = "ERROR: Conflicting flags",
Title = $"{Settings.ErrorPrefix}Conflicting flags",
SubTitle = $"You may not use both {Settings.TimeSpanEndFlag} and {Settings.ResumeFlag} at the same time.",
IcoPath = "tip-error.png",
AutoCompleteText = $"{query.ActionKeyword} {sanitisedQuery} ",
Expand Down Expand Up @@ -2661,7 +2661,7 @@ 1 X X 1 — No span argument
{
usageResult = new Result
{
Title = "ERROR: Span is too large",
Title = $"{Settings.ErrorPrefix}Span is too large",
SubTitle = "The reports span must not exceed 1 year.",
IcoPath = "tip-error.png",
AutoCompleteText = $"{query.ActionKeyword} {queryToSpan} ",
Expand All @@ -2679,7 +2679,7 @@ 1 X X 1 — No span argument
{
usageResult = new Result
{
Title = "ERROR: Invalid reports span",
Title = $"{Settings.ErrorPrefix}Invalid reports span",
SubTitle = "The end date must be after the start date.",
IcoPath = "tip-error.png",
AutoCompleteText = $"{query.ActionKeyword} {queryToSpan} ",
Expand Down

0 comments on commit fba057a

Please sign in to comment.