Add localized error handling for database timeout
Introduced a new localized error message "errorDatabaseTimeout" in multiple languages (English, Kazakh, Russian) and updated the `PanicError` method to handle database timeout errors more gracefully. This improves user feedback by providing context-specific error messages.
This commit is contained in:
		@@ -1,11 +1,14 @@
 | 
				
			|||||||
package error
 | 
					package error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"fyne.io/fyne/v2/container"
 | 
						"fyne.io/fyne/v2/container"
 | 
				
			||||||
 | 
						"fyne.io/fyne/v2/lang"
 | 
				
			||||||
	"fyne.io/fyne/v2/widget"
 | 
						"fyne.io/fyne/v2/widget"
 | 
				
			||||||
	"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
 | 
						"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
 | 
				
			||||||
	"git.kor-elf.net/kor-elf/gui-for-ffmpeg/localizer"
 | 
						"git.kor-elf.net/kor-elf/gui-for-ffmpeg/localizer"
 | 
				
			||||||
	"github.com/nicksnyder/go-i18n/v2/i18n"
 | 
						"github.com/nicksnyder/go-i18n/v2/i18n"
 | 
				
			||||||
 | 
						"go.etcd.io/bbolt"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ViewContract interface {
 | 
					type ViewContract interface {
 | 
				
			||||||
@@ -13,24 +16,38 @@ type ViewContract interface {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type View struct {
 | 
					type View struct {
 | 
				
			||||||
	app kernel.AppContract
 | 
						app           kernel.AppContract
 | 
				
			||||||
 | 
						isSetLanguage bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewView(app kernel.AppContract) *View {
 | 
					func NewView(app kernel.AppContract) *View {
 | 
				
			||||||
	return &View{
 | 
						return &View{
 | 
				
			||||||
		app: app,
 | 
							app:           app,
 | 
				
			||||||
 | 
							isSetLanguage: true,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (v View) PanicError(err error) {
 | 
					func (v View) PanicError(err error) {
 | 
				
			||||||
 | 
						if v.isSetLanguage {
 | 
				
			||||||
 | 
							v.isSetLanguage = false
 | 
				
			||||||
 | 
							_ = v.app.GetLocalizerService().SetCurrentLanguageByCode(lang.SystemLocale().LanguageString())
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	messageHead := v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
 | 
						messageHead := v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
 | 
				
			||||||
		MessageID: "error",
 | 
							MessageID: "error",
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						messagetText := err.Error()
 | 
				
			||||||
 | 
						if errors.Is(err, bbolt.ErrTimeout) {
 | 
				
			||||||
 | 
							messagetText = v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
 | 
				
			||||||
 | 
								MessageID: "errorDatabaseTimeout",
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	v.app.GetWindow().SetContent(container.NewBorder(
 | 
						v.app.GetWindow().SetContent(container.NewBorder(
 | 
				
			||||||
		container.NewVBox(
 | 
							container.NewVBox(
 | 
				
			||||||
			widget.NewLabel(messageHead),
 | 
								widget.NewLabel(messageHead),
 | 
				
			||||||
			widget.NewLabel(err.Error()),
 | 
								widget.NewLabel(messagetText),
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
		nil,
 | 
							nil,
 | 
				
			||||||
		nil,
 | 
							nil,
 | 
				
			||||||
@@ -42,6 +59,11 @@ func (v View) PanicError(err error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (v View) PanicErrorWriteDirectoryData() {
 | 
					func (v View) PanicErrorWriteDirectoryData() {
 | 
				
			||||||
 | 
						if v.isSetLanguage {
 | 
				
			||||||
 | 
							v.isSetLanguage = false
 | 
				
			||||||
 | 
							_ = v.app.GetLocalizerService().SetCurrentLanguageByCode(lang.SystemLocale().LanguageString())
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	message := v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
 | 
						message := v.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
 | 
				
			||||||
		MessageID: "errorDatabase",
 | 
							MessageID: "errorDatabase",
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -222,6 +222,10 @@ other = "Couldn't convert video"
 | 
				
			|||||||
hash = "sha1-531abc3f0d12727e542df6e5a22de91098380fc1"
 | 
					hash = "sha1-531abc3f0d12727e542df6e5a22de91098380fc1"
 | 
				
			||||||
other = "could not create file 'database' in folder 'data'"
 | 
					other = "could not create file 'database' in folder 'data'"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[errorDatabaseTimeout]
 | 
				
			||||||
 | 
					hash = "sha1-f8153516ac2442d19be4b6daccce839d204ff09f"
 | 
				
			||||||
 | 
					other = "Could not open configuration file.\nMake sure another copy of the program is not running!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[errorDragAndDrop1File]
 | 
					[errorDragAndDrop1File]
 | 
				
			||||||
hash = "sha1-a8edb5cbd622f3ce4ec07a2377e22ec5fad4491b"
 | 
					hash = "sha1-a8edb5cbd622f3ce4ec07a2377e22ec5fad4491b"
 | 
				
			||||||
other = "You can only drag and drop 1 file."
 | 
					other = "You can only drag and drop 1 file."
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -222,6 +222,10 @@ other = "Бейнені түрлендіру мүмкін болмады"
 | 
				
			|||||||
hash = "sha1-531abc3f0d12727e542df6e5a22de91098380fc1"
 | 
					hash = "sha1-531abc3f0d12727e542df6e5a22de91098380fc1"
 | 
				
			||||||
other = "'data' қалтасында 'database' файлын жасау мүмкін болмады"
 | 
					other = "'data' қалтасында 'database' файлын жасау мүмкін болмады"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[errorDatabaseTimeout]
 | 
				
			||||||
 | 
					hash = "sha1-f8153516ac2442d19be4b6daccce839d204ff09f"
 | 
				
			||||||
 | 
					other = "Конфигурация файлын аша алмады.\nБағдарламаның басқа көшірмесі іске қосылмағанына көз жеткізіңіз!"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[errorDragAndDrop1File]
 | 
					[errorDragAndDrop1File]
 | 
				
			||||||
hash = "sha1-a8edb5cbd622f3ce4ec07a2377e22ec5fad4491b"
 | 
					hash = "sha1-a8edb5cbd622f3ce4ec07a2377e22ec5fad4491b"
 | 
				
			||||||
other = "Тек 1 файлды сүйреп апаруға болады"
 | 
					other = "Тек 1 файлды сүйреп апаруға болады"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,6 +54,7 @@ encoder_xbm = "XBM (X BitMap) image"
 | 
				
			|||||||
error = "Произошла ошибка!"
 | 
					error = "Произошла ошибка!"
 | 
				
			||||||
errorConverter = "не смогли отконвертировать видео"
 | 
					errorConverter = "не смогли отконвертировать видео"
 | 
				
			||||||
errorDatabase = "не смогли создать файл 'database' в папке 'data'"
 | 
					errorDatabase = "не смогли создать файл 'database' в папке 'data'"
 | 
				
			||||||
 | 
					errorDatabaseTimeout = "Не смогли открыть файл конфигурации.\nУбедитесь, что другая копия программы не запущена!"
 | 
				
			||||||
errorDragAndDrop1File = "Можно перетащить только 1 файл"
 | 
					errorDragAndDrop1File = "Можно перетащить только 1 файл"
 | 
				
			||||||
errorFFmpeg = "это не FFmpeg"
 | 
					errorFFmpeg = "это не FFmpeg"
 | 
				
			||||||
errorFFmpegVersion = "Не смогли определить версию FFmpeg"
 | 
					errorFFmpegVersion = "Не смогли определить версию FFmpeg"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user