From 4ef067cba11c91a2c8b4ffaf1247ad420545e864 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 16 Oct 2025 13:32:28 -0500 Subject: not sure about this panic --- errors.go | 2 ++ load.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/errors.go b/errors.go index 7f318af..154f3af 100644 --- a/errors.go +++ b/errors.go @@ -7,6 +7,8 @@ import ( var NotInitialized error = errors.New("your application config not initialized") +var VersionMismatch error = errors.New("your PB version does not match") + // Finally, declare a package-level variable of your new type. // This is the "sentinel" error that users will compare against. var ErrNotInitialized = NotInitializedError{} diff --git a/load.go b/load.go index 2434f9e..c9fef7d 100644 --- a/load.go +++ b/load.go @@ -116,11 +116,17 @@ func LoadPB(pb proto.Message) error { } newver, _ := GetString(pb, "version") if ver != newver { + fmt.Println("") fmt.Printf("VERSION '%s' != '%s'\n", ver, newver) + fmt.Println("") fmt.Println("Your protobuf file is old and can not be loaded") + fmt.Println("your application must decide how to handle this (delete or fix)") + fmt.Println("always panic here. application is broken") fmt.Println("You must delete or convert the file", fullname) - // probably should ALWAYS PANIC HERE - panic("protobuf version mismatch") + fmt.Println("") + // probably should ALWAYS PANIC HERE // upon further study, always panic here is better than not + s := fmt.Sprintf("protobuf version wrong. delete or fix %s", fullname) + panic(s) } return nil } -- cgit v1.2.3