Skip to content

Commit

Permalink
Stop 'Page has no searchable content' error notif
Browse files Browse the repository at this point in the history
- this error should never show a notif; it's not related to users
- addresses WorldBrain#838
  • Loading branch information
poltak committed Jun 17, 2019
1 parent aa78b10 commit ef61f5f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/activity-logger/background/log-page-visit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ export default class PageVisitLogger {
})
} catch (err) {
this._tabManager.clearScheduledLog(tab.id)
throw err

if (!(err instanceof searchIndex.PipelineError)) {
throw err
}
}
}

Expand Down Expand Up @@ -144,9 +147,15 @@ export default class PageVisitLogger {
return
}

await this._createPage({
pageDoc,
visits: [internalTabState.visitTime],
})
try {
await this._createPage({
pageDoc,
visits: [internalTabState.visitTime],
})
} catch (err) {
if (!(err instanceof searchIndex.PipelineError)) {
throw err
}
}
}
}
2 changes: 2 additions & 0 deletions src/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export * from './on-demand-indexing'
export * from './types'
export * from './models'
export { default as getDb } from './get-db'

export { PipelineError } from './pipeline'
6 changes: 5 additions & 1 deletion src/search/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import transformPageText from '../util/transform-page-text'
import { DEFAULT_TERM_SEPARATOR, extractContent } from './util'
import { PipelineReq, PipelineRes } from './types'

export class PipelineError extends Error {}

/**
* Derived from answer in: https://stackoverflow.com/a/23945027
*/
Expand Down Expand Up @@ -105,7 +107,9 @@ export default function pipeline({
rejectNoContent &&
(content == null || !content.fullText || !content.fullText.length)
) {
return Promise.reject(new Error('Page has no searchable content'))
return Promise.reject(
new PipelineError('Page has no searchable content'),
)
}

// Extract all terms out of processed content
Expand Down

0 comments on commit ef61f5f

Please sign in to comment.