Skip to content

Commit 8252c14

Browse files
authored
Merge pull request #52 from per1234/improve-error-messages
Improve readability of error messages
2 parents 2b2b21f + 6058b88 commit 8252c14

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ func main() {
149149
}
150150

151151
// Assemble the index entry for the submissions.
152+
// Note: %0A must be used for line breaks in all strings that will be used as step/job outputs in the GitHub Actions
153+
// workflow. In that application, any text following \n is discarded.
152154
req.IndexEntry = strings.Join(indexEntries, "%0A")
153155

154156
// Assemble the list of Library Manager indexer logs URLs for the submissions to show in the acceptance message.
@@ -260,7 +262,7 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT
260262

261263
// Check if URL is from a supported Git host.
262264
if !uRLIsUnder(normalizedURLObject, supportedHosts) {
263-
submission.Error = normalizedURLObject.Host + " is not currently supported as a Git hosting website for Library Manager.%0ASee: https://github.com/arduino/library-registry/blob/main/FAQ.md#what-are-the-requirements-for-a-library-to-be-added-to-library-manager"
265+
submission.Error = fmt.Sprintf("`%s` is not currently supported as a Git hosting website for Library Manager.%%0A%%0ASee: https://github.com/arduino/library-registry/blob/main/FAQ.md#what-are-the-requirements-for-a-library-to-be-added-to-library-manager", normalizedURLObject.Host)
264266
return submission, ""
265267
}
266268

@@ -350,18 +352,18 @@ func populateSubmission(submissionURL string, listPath *paths.Path) (submissionT
350352
// Get submission library name. It is necessary to record this in the index source entry because the library is locked to this name.
351353
libraryPropertiesPath := submissionClonePath.Join("library.properties")
352354
if !libraryPropertiesPath.Exist() {
353-
submission.Error = "Library is missing a library.properties metadata file."
355+
submission.Error = "Library is missing a library.properties metadata file.%0A%0ASee: https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata"
354356
return submission, ""
355357
}
356358
libraryProperties, err := properties.LoadFromPath(libraryPropertiesPath)
357359
if err != nil {
358-
submission.Error = fmt.Sprintf("Invalid library.properties file (%s)", err)
360+
submission.Error = fmt.Sprintf("Invalid library.properties file: %s%%0A%%0ASee: https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata", err)
359361
return submission, ""
360362
}
361363
var ok bool
362364
submission.Name, ok = libraryProperties.GetOk("name")
363365
if !ok {
364-
submission.Error = "library.properties is missing a name field"
366+
submission.Error = "library.properties is missing a name field.%0A%0ASee: https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata"
365367
return submission, ""
366368
}
367369

test/test_all.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@
9090
"name": "",
9191
"official": False,
9292
"tag": "",
93-
"error": "example.com is not currently supported as a Git hosting website for Library Manager.%0A"
94-
"See: https://github.com/arduino/library-registry/blob/main/FAQ.md#what-are-the-requirements-for-a-"
95-
"library-to-be-added-to-library-manager",
93+
"error": "`example.com` is not currently supported as a Git hosting website for Library Manager.%0A"
94+
"%0ASee: https://github.com/arduino/library-registry/blob/main/FAQ.md#what-are-the-requirements-for"
95+
"-a-library-to-be-added-to-library-manager",
9696
}
9797
],
9898
"",
@@ -232,7 +232,8 @@
232232
"name": "",
233233
"official": True,
234234
"tag": "1.0.1",
235-
"error": "Library is missing a library.properties metadata file.",
235+
"error": "Library is missing a library.properties metadata file.%0A%0A"
236+
"See: https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata",
236237
}
237238
],
238239
"",

0 commit comments

Comments
 (0)