mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
feat: simple client manager
This commit is contained in:
@ -78,8 +78,6 @@ func newConfig(appName, version, revision, cacheVersion string, appDirs, appDirs
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ResponseHeaderTimeout: 10 * time.Second,
|
||||
},
|
||||
// TokenManager should not be required, but PMAPI still doesn't handle not-set cases everywhere.
|
||||
TokenManager: pmapi.NewTokenManager(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,9 +64,11 @@ func GetLogEntry(packageName string) *logrus.Entry {
|
||||
// HandlePanic reports the crash to sentry or local file when sentry fails.
|
||||
func HandlePanic(cfg *Config, output string) {
|
||||
if !cfg.IsDevMode() {
|
||||
c := pmapi.NewClient(cfg.GetAPIConfig(), "no-user-id")
|
||||
err := c.ReportSentryCrash(fmt.Errorf(output))
|
||||
if err != nil {
|
||||
// TODO: Is it okay to just create a throwaway client like this?
|
||||
c := pmapi.NewClientManager(cfg.GetAPIConfig()).GetClient("no-user-id")
|
||||
defer func() { _ = c.Logout() }()
|
||||
|
||||
if err := c.ReportSentryCrash(fmt.Errorf(output)); err != nil {
|
||||
log.Error("Sentry crash report failed: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user