Skip to content

Commit

Permalink
Error reporting bug fixes
Browse files Browse the repository at this point in the history
- `Scoop.#capturePageInfo()`: Account for data URL favicons.
- **CLI:** In certain cases, invalid combinations of options would lead to the program exiting without printing an error message.
  • Loading branch information
matteocargnelutti committed Apr 21, 2023
1 parent 03f5485 commit ca8e5b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion Scoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,22 @@ export class Scoop {
}
})

//
// Favicon processing
//

// Not needed if:
// - No favicon URL found
// - Favicon url is not an http(s) URL
if (!this.pageInfo?.faviconUrl) {
return
}

// If `headless`: request the favicon using curl.
if (!this.pageInfo.faviconUrl.startsWith('http')) {
return
}

// If `headless`: request the favicon using curl so it's added to the exchanges list.
if (this.options.headless) {
try {
const userAgent = await page.evaluate(() => window.navigator.userAgent) // Source user agent from the browser
Expand Down
6 changes: 5 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,11 @@ program.action(async (name, options, command) => {
url = command.processedArgs[0]
capture = await Scoop.capture(url, options)
} catch (err) {
process.exit(1) // Logs handled by Scoop
// Logs are handled by Scoop directly, unless `Scoop.capture` fails during initialization
if (!capture) {
console.error(err.message)
}
process.exit(1)
}

//
Expand Down

0 comments on commit ca8e5b2

Please sign in to comment.