mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 22:29:38 +00:00
Added database connection error handling
This commit is contained in:
@@ -21,7 +21,12 @@ export class SearchService {
|
||||
if (this.awaitingResults) { return }
|
||||
this.awaitingResults = true
|
||||
this.currentQuery = { query, type: SearchType.Any, offset: 0, length: 50 + 1 } // TODO: make length a setting
|
||||
this.results = this.trimLastChart(await this.electronService.invoke('song-search', this.currentQuery))
|
||||
try {
|
||||
this.results = this.trimLastChart(await this.electronService.invoke('song-search', this.currentQuery))
|
||||
} catch (err) {
|
||||
this.results = []
|
||||
this.resultsChangedEmitter.error(undefined)
|
||||
}
|
||||
this.awaitingResults = false
|
||||
|
||||
this.resultsChangedEmitter.emit(this.results)
|
||||
@@ -49,6 +54,14 @@ export class SearchService {
|
||||
this.newResultsEmitter.subscribe(callback)
|
||||
}
|
||||
|
||||
/**
|
||||
* Event emitted when a search fails.
|
||||
* (emitted before `onSearchChanged`)
|
||||
*/
|
||||
onSearchError(callback: () => void) {
|
||||
this.resultsChangedEmitter.subscribe(() => { /** Do nothing */ }, callback)
|
||||
}
|
||||
|
||||
get resultCount() {
|
||||
return this.results.length
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user