Skip to content

Commit

Permalink
Make it loud which URL failed in sync-search (github#35434)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Mar 9, 2023
1 parent 2bd845f commit 0a23f97
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 59 deletions.
77 changes: 19 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"ajv-errors": "^3.0.0",
"ajv-formats": "^2.1.1",
"bottleneck": "2.19.5",
"boxen": "7.0.2",
"cheerio": "^1.0.0-rc.11",
"cheerio-to-text": "0.2.2",
"classnames": "^2.3.1",
Expand Down
17 changes: 16 additions & 1 deletion script/search/build-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import eventToPromise from 'event-to-promise'
import chalk from 'chalk'
import dotenv from 'dotenv'
import boxen from 'boxen'
import { HTTPError } from 'got'

import parsePageSectionsIntoRecords from './parse-page-sections-into-records.js'
import getPopularPages from './popular-pages.js'
import languages from '../../lib/languages.js'
Expand Down Expand Up @@ -72,7 +75,19 @@ export default async function buildRecords(
records.push(newRecord)
})
.on('error', (err) => {
console.error(err)
if (err instanceof HTTPError && !err.response.ok) {
console.log(
'\n' +
boxen(chalk.bold(err.request.requestUrl.pathname), {
title: chalk.red('The URL it failed on was'),
padding: 1,
borderColor: 'red',
}) +
'\n'
)
} else {
console.error(err)
}
})

return eventToPromise(waiter, 'done').then(() => {
Expand Down

0 comments on commit 0a23f97

Please sign in to comment.