From 3ba96709fa292d006d3594e0bdf0e63669f132b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Beir=C3=A3o?= Date: Fri, 2 Jun 2023 12:11:13 +0200 Subject: [PATCH] Add nice error message for Problem::InvalidUrl(UrlProblem::MissingHttps) Contributes to #5487 --- crates/reporting/src/report.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/reporting/src/report.rs b/crates/reporting/src/report.rs index b8ae4a396f..388236dcb0 100644 --- a/crates/reporting/src/report.rs +++ b/crates/reporting/src/report.rs @@ -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([