From b6ba48b2ab3c1ab2b3e6c154fa2b7fab9b6b4d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Sun, 24 Feb 2019 23:32:05 +0100 Subject: [PATCH] updated errorhandling again --- internal/app/app.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/app/app.go b/internal/app/app.go index dc5c7a2..0166798 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -22,8 +22,10 @@ func Run() { os.Exit(1) } - loginToPiwigoAndConfigureContext(context) - + err = loginToPiwigoAndConfigureContext(context) + if err != nil { + os.Exit(2) + } //ScanLocalDirectories(context) //GetAllCategoriesFromServer() @@ -92,20 +94,21 @@ func configureContext() (*AppContext, error) { return context, nil } -func loginToPiwigoAndConfigureContext(context *AppContext) { +func loginToPiwigoAndConfigureContext(context *AppContext) error { logrus.Infoln("Logging in to piwigo and getting chunk size configuration for uploads") err := authentication.Login(context.Piwigo) if err != nil { - panic(err) + return err } - initializeUploadChunkSize(context) + return initializeUploadChunkSize(context) } -func initializeUploadChunkSize(context *AppContext) { +func initializeUploadChunkSize(context *AppContext) error { userStatus, err := authentication.GetStatus(context.Piwigo) if err != nil { - panic(err) + return err } context.ChunkSizeBytes = userStatus.Result.UploadFormChunkSize * 1024 logrus.Debugln(context.ChunkSizeBytes) + return nil }