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

Improve a couple of http kernel error messages #3442

Merged
merged 1 commit into from
Feb 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ internal static HttpDiagnosticInfo InvalidOffset(string expression, string offse
{
var id = $"HTTP0015";
var severity = DiagnosticSeverity.Error;
var messageFormat = "The supplied offset '{1}' in the expression '{0}' is not a valid integer.";
var messageFormat = "The supplied offset '{1}' in the expression '{0}' is not a valid integer. See https://aka.ms/http-date-time-format for more details.";
shyamnamboodiripad marked this conversation as resolved.
Show resolved Hide resolved
return new HttpDiagnosticInfo(id, messageFormat, severity, expression, offset);
}

internal static HttpDiagnosticInfo InvalidOption(string expression, string option)
{
var id = $"HTTP0016";
var severity = DiagnosticSeverity.Error;
var messageFormat = "The supplied option '{1}' in the expression '{0}' is not supported.";
var messageFormat = "The supplied option '{1}' in the expression '{0}' is not supported. The following options are supported: ms, s, m, h, d, w, M, Q, y. See https://aka.ms/http-date-time-format for more details.";
shyamnamboodiripad marked this conversation as resolved.
Show resolved Hide resolved
return new HttpDiagnosticInfo(id, messageFormat, severity, expression, option);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ public async Task cant_bind_timestamp_offset_with_invalid_option()

var diagnostics = result.Events.Should().ContainSingle<DiagnosticsProduced>().Which;

diagnostics.Diagnostics.First().Message.Should().Be("The supplied option 'q' in the expression '$timestamp -1 q' is not supported.");
diagnostics.Diagnostics.First().Message.Should().Be("The supplied option 'q' in the expression '$timestamp -1 q' is not supported. The following options are supported: ms, s, m, h, d, w, M, Q, y. See https://aka.ms/http-date-time-format for more details.");
shyamnamboodiripad marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down Expand Up @@ -834,7 +834,7 @@ public async Task cant_bind_timestamp_offset_with_invalid_offset()

var diagnostics = result.Events.Should().ContainSingle<DiagnosticsProduced>().Which;

diagnostics.Diagnostics.First().Message.Should().Be("The supplied offset '33.2' in the expression '$timestamp 33.2 d' is not a valid integer.");
diagnostics.Diagnostics.First().Message.Should().Be("The supplied offset '33.2' in the expression '$timestamp 33.2 d' is not a valid integer. See https://aka.ms/http-date-time-format for more details.");
shyamnamboodiripad marked this conversation as resolved.
Show resolved Hide resolved
}

[Fact]
Expand Down Expand Up @@ -862,7 +862,7 @@ public async Task cant_bind_timestamp_with_invalid_chars_in_the_arguments()

var result = await kernel.SendAsync(new SubmitCode(code));

result.Events.Should().ContainSingle<DiagnosticsProduced>().Which.Diagnostics.Should().ContainSingle().Which.Message.Should().Be("The supplied offset '~1' in the expression '$timestamp ~1 d' is not a valid integer.");
result.Events.Should().ContainSingle<DiagnosticsProduced>().Which.Diagnostics.Should().ContainSingle().Which.Message.Should().Be("The supplied offset '~1' in the expression '$timestamp ~1 d' is not a valid integer. See https://aka.ms/http-date-time-format for more details.");
shyamnamboodiripad marked this conversation as resolved.
Show resolved Hide resolved
}

[Fact]
Expand Down Expand Up @@ -1194,7 +1194,7 @@ public async Task invalid_option_produces_error()
""";

var result = await kernel.SendAsync(new SubmitCode(code));
result.Events.Should().ContainSingle<DiagnosticsProduced>().Which.Diagnostics.Should().ContainSingle().Which.Message.Should().Be("The supplied option 't' in the expression '$datetime 'yyyy-MM-dd' -1 t' is not supported.");
result.Events.Should().ContainSingle<DiagnosticsProduced>().Which.Diagnostics.Should().ContainSingle().Which.Message.Should().Be("The supplied option 't' in the expression '$datetime 'yyyy-MM-dd' -1 t' is not supported. The following options are supported: ms, s, m, h, d, w, M, Q, y. See https://aka.ms/http-date-time-format for more details.");
Copy link
Member

Choose a reason for hiding this comment

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

do we need this to be localised?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, all of the parser diagnostics need to be localized. And since the parser package is source-only, we need to do be able to localize in both the current repo and the internal repo. We have discussed this before and have some ideas around how to do this. There will be a follow up PR around this before long.

}

[Fact]
Expand Down
Loading