diff --git a/backend/bindings/ficsitcli/installs.go b/backend/bindings/ficsitcli/installs.go index c3d71b51..ede33452 100644 --- a/backend/bindings/ficsitcli/installs.go +++ b/backend/bindings/ficsitcli/installs.go @@ -131,7 +131,7 @@ func (f *FicsitCLI) GetInvalidInstalls() []string { result := []string{} for _, err := range f.installFindErrors { var installFindErr common.InstallFindError - if ok := errors.As(err, &installFindErr); ok { + if errors.As(err, &installFindErr) { result = append(result, installFindErr.Path) } } @@ -179,7 +179,7 @@ func (f *FicsitCLI) SelectInstall(path string) error { if installErr != nil { l.Error("failed to validate install", slog.Any("error", installErr)) - return errors.Wrap(installErr, "Failed to validate install") + return installErr } return nil } @@ -224,7 +224,7 @@ func (f *FicsitCLI) SetModsEnabled(enabled bool) error { if installErr != nil { l.Error("failed to validate install", slog.Any("error", installErr)) - return errors.Wrap(installErr, "failed to validate install") + return installErr } return nil @@ -248,7 +248,7 @@ func (f *FicsitCLI) GetSelectedInstallLockfileMods() (map[string]resolver.Locked } lockfile, err := f.selectedInstallation.Installation.LockFile(f.ficsitCli) if err != nil { - return nil, errors.Wrap(err, "failed to get lockfile") + return nil, err //nolint:wrapcheck } if lockfile == nil { return make(map[string]resolver.LockedMod), nil @@ -262,7 +262,7 @@ func (f *FicsitCLI) GetSelectedInstallLockfile() (*resolver.LockFile, error) { } lockfile, err := f.selectedInstallation.Installation.LockFile(f.ficsitCli) if err != nil { - return nil, errors.Wrap(err, "failed to get lockfile") + return nil, err //nolint:wrapcheck } return lockfile, nil } diff --git a/backend/bindings/ficsitcli/process.go b/backend/bindings/ficsitcli/process.go index 0b889947..a2b2e372 100644 --- a/backend/bindings/ficsitcli/process.go +++ b/backend/bindings/ficsitcli/process.go @@ -10,6 +10,7 @@ import ( "github.com/puzpuzpuz/xsync/v3" "github.com/satisfactorymodding/ficsit-cli/cli" ficsitUtils "github.com/satisfactorymodding/ficsit-cli/utils" + resolver "github.com/satisfactorymodding/ficsit-resolver" wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" "github.com/satisfactorymodding/SatisfactoryModManager/backend/utils" @@ -154,7 +155,11 @@ func (f *FicsitCLI) validateInstall(installation *InstallationInfo, progressItem installErr := installation.Installation.Install(f.ficsitCli, installChannel) if installErr != nil { - return errors.Wrap(installErr, "failed to install") + var solvingError resolver.DependencyResolverError + if errors.As(installErr, &solvingError) { + return solvingError + } + return installErr //nolint:wrapcheck } return nil } @@ -202,11 +207,14 @@ func (f *FicsitCLI) InstallMod(mod string) error { return errors.New("no installation selected") } + l := slog.With(slog.String("task", "installMod"), slog.String("mod", mod), utils.SlogPath("install", f.selectedInstallation.Info.Path)) + profileName := f.selectedInstallation.Installation.Profile profile := f.GetProfile(profileName) profileErr := profile.AddMod(mod, ">=0.0.0") if profileErr != nil { + l.Error("failed to add mod", slog.Any("error", profileErr)) return errors.Wrapf(profileErr, "failed to add mod: %s@latest", mod) } @@ -223,7 +231,8 @@ func (f *FicsitCLI) InstallMod(mod string) error { installErr := f.validateInstall(f.selectedInstallation, mod) if installErr != nil { - return errors.Wrapf(installErr, "failed to install mod: %s@latest", mod) + l.Error("failed to install", slog.Any("error", installErr)) + return installErr } _ = f.ficsitCli.Profiles.Save() @@ -240,12 +249,15 @@ func (f *FicsitCLI) InstallModVersion(mod string, version string) error { return errors.New("no installation selected") } + l := slog.With(slog.String("task", "installModVersion"), slog.String("mod", mod), slog.String("version", version), utils.SlogPath("install", f.selectedInstallation.Info.Path)) + profileName := f.selectedInstallation.Installation.Profile profile := f.GetProfile(profileName) profileErr := profile.AddMod(mod, version) if profileErr != nil { - return errors.Wrapf(profileErr, "Failed to add mod: %s@%s", mod, version) + l.Error("failed to add mod", slog.Any("error", profileErr)) + return errors.Wrapf(profileErr, "failed to add mod: %s@%s", mod, version) } f.progress = &Progress{ @@ -261,7 +273,8 @@ func (f *FicsitCLI) InstallModVersion(mod string, version string) error { installErr := f.validateInstall(f.selectedInstallation, mod) if installErr != nil { - return errors.Wrapf(installErr, "failed to install mod: %s@%s", mod, version) + l.Error("failed to install", slog.Any("error", installErr)) + return installErr } _ = f.ficsitCli.Profiles.Save() @@ -278,6 +291,8 @@ func (f *FicsitCLI) RemoveMod(mod string) error { return errors.New("no installation selected") } + l := slog.With(slog.String("task", "removeMod"), slog.String("mod", mod), utils.SlogPath("install", f.selectedInstallation.Info.Path)) + profileName := f.selectedInstallation.Installation.Profile profile := f.GetProfile(profileName) @@ -296,7 +311,8 @@ func (f *FicsitCLI) RemoveMod(mod string) error { installErr := f.validateInstall(f.selectedInstallation, mod) if installErr != nil { - return errors.Wrapf(installErr, "failed to remove mod: %s", mod) + l.Error("failed to install", slog.Any("error", installErr)) + return installErr } _ = f.ficsitCli.Profiles.Save() @@ -313,6 +329,8 @@ func (f *FicsitCLI) EnableMod(mod string) error { return errors.New("no installation selected") } + l := slog.With(slog.String("task", "enableMod"), slog.String("mod", mod), utils.SlogPath("install", f.selectedInstallation.Info.Path)) + profileName := f.selectedInstallation.Installation.Profile profile := f.GetProfile(profileName) @@ -331,7 +349,8 @@ func (f *FicsitCLI) EnableMod(mod string) error { installErr := f.validateInstall(f.selectedInstallation, mod) if installErr != nil { - return errors.Wrapf(installErr, "failed to enable mod: %s", mod) + l.Error("failed to install", slog.Any("error", installErr)) + return installErr } _ = f.ficsitCli.Profiles.Save() @@ -348,6 +367,8 @@ func (f *FicsitCLI) DisableMod(mod string) error { return errors.New("no installation selected") } + l := slog.With(slog.String("task", "disableMod"), slog.String("mod", mod), utils.SlogPath("install", f.selectedInstallation.Info.Path)) + profileName := f.selectedInstallation.Installation.Profile profile := f.GetProfile(profileName) @@ -366,7 +387,8 @@ func (f *FicsitCLI) DisableMod(mod string) error { installErr := f.validateInstall(f.selectedInstallation, mod) if installErr != nil { - return errors.Wrapf(installErr, "failed to disable mod: %s", mod) + l.Error("failed to install", slog.Any("error", installErr)) + return installErr } _ = f.ficsitCli.Profiles.Save() diff --git a/backend/bindings/ficsitcli/profiles.go b/backend/bindings/ficsitcli/profiles.go index e8d1b8d9..c37fa272 100644 --- a/backend/bindings/ficsitcli/profiles.go +++ b/backend/bindings/ficsitcli/profiles.go @@ -49,7 +49,7 @@ func (f *FicsitCLI) SetProfile(profile string) error { if installErr != nil { l.Error("failed to validate installation", slog.Any("error", installErr)) - return errors.Wrap(installErr, "Failed to validate install") + return installErr } return nil @@ -290,7 +290,7 @@ func (f *FicsitCLI) ImportProfile(name string, file string) error { if installErr != nil { _ = f.ficsitCli.Profiles.DeleteProfile(name) l.Error("failed to validate installation", slog.Any("error", installErr)) - return errors.Wrap(installErr, "Failed to validate install") + return installErr } _ = f.ficsitCli.Profiles.Save() diff --git a/backend/bindings/ficsitcli/update.go b/backend/bindings/ficsitcli/update.go index a7c8f86b..53c32146 100644 --- a/backend/bindings/ficsitcli/update.go +++ b/backend/bindings/ficsitcli/update.go @@ -33,7 +33,7 @@ func (f *FicsitCLI) CheckForUpdates() ([]Update, error) { profile := f.GetProfile(f.selectedInstallation.Installation.Profile) - resolver := resolver.NewDependencyResolver(f.ficsitCli.Provider, viper.GetString("api-base")) + res := resolver.NewDependencyResolver(f.ficsitCli.Provider, viper.GetString("api-base")) gameVersion, err := f.selectedInstallation.Installation.GetGameVersion(f.ficsitCli) if err != nil { @@ -51,10 +51,14 @@ func (f *FicsitCLI) CheckForUpdates() ([]Update, error) { Version: ">=0.0.0", } } - newLockfile, err := updateProfile.Resolve(resolver, nil, gameVersion) + newLockfile, err := updateProfile.Resolve(res, nil, gameVersion) if err != nil { l.Error("failed to resolve dependencies", slog.Any("error", err)) - return nil, errors.Wrap(err, "Error resolving dependencies") + var solvingError resolver.DependencyResolverError + if errors.As(err, &solvingError) { + return nil, solvingError + } + return nil, err //nolint:wrapcheck } updates := []Update{} @@ -101,7 +105,11 @@ func (f *FicsitCLI) UpdateMods(mods []string) error { err := f.selectedInstallation.Installation.UpdateMods(f.ficsitCli, mods) if err != nil { l.Error("failed to update mods", slog.Any("error", err)) - return errors.Wrap(err, "Failed to update mods") + var solvingError resolver.DependencyResolverError + if errors.As(err, &solvingError) { + return solvingError + } + return err //nolint:wrapcheck } f.progress = &Progress{ @@ -118,7 +126,11 @@ func (f *FicsitCLI) UpdateMods(mods []string) error { if err != nil { l.Error("failed to validate installation", slog.Any("error", err)) - return errors.Wrap(err, "Failed to validate installation") + var solvingError resolver.DependencyResolverError + if errors.As(err, &solvingError) { + return solvingError + } + return err } _ = f.ficsitCli.Profiles.Save()