mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	better error reporting on failed search
This commit is contained in:
		
							parent
							
								
									2b1383205b
								
							
						
					
					
						commit
						bdebb35f62
					
				| @ -165,7 +165,7 @@ export default class Entrypoints extends Component { | |||||||
|         const response = await server.get('search/' + encodeURIComponent(searchText) + '?includeNoteContent=true&excludeArchived=true&fuzzyAttributeSearch=false'); |         const response = await server.get('search/' + encodeURIComponent(searchText) + '?includeNoteContent=true&excludeArchived=true&fuzzyAttributeSearch=false'); | ||||||
| 
 | 
 | ||||||
|         if (!response.success) { |         if (!response.success) { | ||||||
|             toastService.showError("Search failed.", 3000); |             toastService.showError("Search failed: " + response.message, 10000); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -17,7 +17,8 @@ function searchNotes(req) { | |||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|         return { |         return { | ||||||
|             success: true, |             success: !searchContext.hasError(), | ||||||
|  |             message: searchContext.getError(), | ||||||
|             count, |             count, | ||||||
|             results |             results | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -16,6 +16,14 @@ class SearchContext { | |||||||
|             this.error = error; |             this.error = error; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     hasError() { | ||||||
|  |         return !!this.error; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     getError() { | ||||||
|  |         return this.error; | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = SearchContext; | module.exports = SearchContext; | ||||||
|  | |||||||
| @ -263,7 +263,13 @@ function getExpression(tokens, searchContext, level = 0) { | |||||||
|             i += 1; |             i += 1; | ||||||
| 
 | 
 | ||||||
|             return new RelationWhereExp(relationName, parseNoteProperty()); |             return new RelationWhereExp(relationName, parseNoteProperty()); | ||||||
|         } else { |         } | ||||||
|  |         else if (i < tokens.length - 2 && isOperator(tokens[i + 1].token)) { | ||||||
|  |             searchContext.addError(`Relation can be compared only with property, e.g. ~relation.title=hello in ${context(i)}`); | ||||||
|  | 
 | ||||||
|  |             return null; | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|             return new AttributeExistsExp('relation', relationName, searchContext.fuzzyAttributeSearch); |             return new AttributeExistsExp('relation', relationName, searchContext.fuzzyAttributeSearch); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -73,6 +73,8 @@ function findNotesWithQuery(query, searchContext) { | |||||||
|         return []; |         return []; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     searchContext.originalQuery = query; | ||||||
|  | 
 | ||||||
|     return utils.stopWatch(`Search with query "${query}"`, () => { |     return utils.stopWatch(`Search with query "${query}"`, () => { | ||||||
|         const expression = parseQueryToExpression(query, searchContext); |         const expression = parseQueryToExpression(query, searchContext); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam