Add nice error message for Problem::InvalidUrl(UrlProblem::MissingHttps)

Contributes to #5487
This commit is contained in:
Fábio Beirão 2023-06-02 12:11:13 +02:00
parent b1321659c5
commit 3ba96709fa
No known key found for this signature in database
GPG key ID: 13FD3A2130278AAE

View file

@ -1440,6 +1440,32 @@ pub fn to_https_problem_report<'b>(
severity: Severity::Fatal,
}
}
Problem::InvalidUrl(roc_packaging::https::UrlProblem::MissingHttps) => {
let doc = alloc.stack([
alloc.reflow(r"I was trying to download this URL:"),
alloc
.string((&url).to_string())
.annotate(Annotation::Url)
.indent(4),
alloc.concat([
alloc.reflow(r"For your security, I will only attempt to download "),
alloc.reflow(r"files from servers which use the "),
alloc.keyword(r"https"),
alloc.reflow(r" protocol."),
]),
alloc.concat([
alloc.tip(),
alloc.reflow(r"Check that you have the correct URL for this package/platform."),
]),
]);
Report {
filename: "UNKNOWN.roc".into(),
doc,
title: "HTTPS MANDATORY".to_string(),
severity: Severity::Fatal,
}
}
_ => {
// TODO: once all patterns are there, we should remove the _
let doc = alloc.stack([