mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	client: Display errors for right panel widgets instead of crashing
This commit is contained in:
		
							parent
							
								
									584ba246e3
								
							
						
					
					
						commit
						0ba9fc7f5b
					
				| @ -1,4 +1,6 @@ | ||||
| import NoteContextAwareWidget from "./note_context_aware_widget.js"; | ||||
| import toastService from "../services/toast.js"; | ||||
| import { t } from "../services/i18n.js"; | ||||
| 
 | ||||
| const WIDGET_TPL = ` | ||||
| <div class="card widget"> | ||||
| @ -54,7 +56,19 @@ class RightPanelWidget extends NoteContextAwareWidget { | ||||
|             this.$buttons.append(buttonWidget.render()); | ||||
|         } | ||||
| 
 | ||||
|         try { | ||||
|             this.initialized = this.doRenderBody(); | ||||
|         } catch (e) { | ||||
|             toastService.showPersistent({ | ||||
|                 title: t("toast.widget-error.title"), | ||||
|                 icon: "alert", | ||||
|                 message: t("toast.widget-error.message", { | ||||
|                     title: this.widgetTitle, | ||||
|                     message: e.message | ||||
|                 }) | ||||
|             }); | ||||
|             logError(e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -13,6 +13,10 @@ | ||||
|     "critical-error": { | ||||
|       "title": "Critical error", | ||||
|       "message": "A critical error has occurred which prevents the client application from starting:\n\n{{message}}\n\nThis is most likely caused by a script failing in an unexpected way. Try starting the application in safe mode and addressing the issue." | ||||
|     }, | ||||
|     "widget-error": { | ||||
|       "title": "Failed to initialize a widget", | ||||
|       "message": "Widget with title \"{{title}}\" could not be initialized due to:\n\n{{message}}" | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran