Skip to content

Commit

Permalink
Small error updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SirLich committed Feb 12, 2022
1 parent ff46913 commit 4578f0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
16 changes: 9 additions & 7 deletions regolith/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ func GetExportPaths(
if exportTarget.Target == "development" {
comMojang, err := FindMojangDir()
if err != nil {
return "", "", WrapError(err, "failed to find com.mojang directory")
return "", "", WrapError(err, "failed to find com.mojang directory.")
}

// TODO - I don't like the _rp and _bp sufixes. Can we get rid of that?
// I for example always name my packs "0".
bpPath = comMojang + "/development_behavior_packs/" + name + "_bp"
Expand Down Expand Up @@ -76,7 +77,7 @@ func ExportProject(profile Profile, name string, dataPath string) error {
exportTarget := profile.ExportTarget
bpPath, rpPath, err := GetExportPaths(exportTarget, name)
if err != nil {
return WrapError(err, "failed to get export paths")
return WrapError(err, "Failed to get generate export paths. Is your export target correct?")
}

// Loading edited_files.json or creating empty object
Expand All @@ -96,21 +97,22 @@ func ExportProject(profile Profile, name string, dataPath string) error {
err = os.RemoveAll(bpPath)
if err != nil {
return WrapErrorf(
err, "failed to clear behavior pack build output path: %q", bpPath)
err, "Failed to clear behavior pack from build path %q. Are user permissions correct?", bpPath)
}
err = os.RemoveAll(rpPath)
if err != nil {
return WrapErrorf(
err, "failed to clear resource pack build output path: %q", rpPath)
err, "Failed to clear resource pack from build path %q. Are user permissions correct?", rpPath)
}
// TODO - this code is dangerous. You can put any dataPath into the config
// file and regolith will delete it
err = os.RemoveAll(dataPath)
if err != nil {
return WrapErrorf(
err, "failed to clear filter data path: %q", dataPath)
err, "failed to clear filter data path to %q", dataPath)
}
Logger.Info("Exporting project to ", bpPath)

Logger.Infof("Exporting behavior pack to %q", bpPath)
err = MoveOrCopy(".regolith/tmp/BP", bpPath, exportTarget.ReadOnly, true)
if err != nil {
return WrapError(err, "failed to export behavior pack")
Expand All @@ -120,13 +122,13 @@ func ExportProject(profile Profile, name string, dataPath string) error {
if err != nil {
return WrapError(err, "failed to export resource pack")
}

err = MoveOrCopy(".regolith/tmp/data", dataPath, false, false)
if err != nil {
return WrapError(
err,
"failed to move the filter data back to the project's data folder")
}

// Update or create edited_files.json
err = editedFiles.UpdateFromPaths(rpPath, bpPath)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions regolith/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func CreateDirectoryIfNotExists(directory string, mustSucceed bool) error {
if err != nil {
if mustSucceed {
return WrapErrorf(
err, "failed to create directory %s", directory)
err, "Failed to create directory %s", directory)
} else {
Logger.Warnf("failed to create directory %s: %s", directory, err.Error())
Logger.Warnf("Failed to create directory %s: %s", directory, err.Error())
return nil
}
}
Expand Down
6 changes: 3 additions & 3 deletions regolith/utils_minecraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ func ListWorlds(mojangDir string) ([]*World, error) {

func FindMojangDir() (string, error) {
if runtime.GOOS != "windows" {
return "", WrapErrorf(nil, "unsupported OS '%s'", runtime.GOOS)
return "", WrapErrorf(nil, "Unsupported operating system: '%s'", runtime.GOOS)
}
result := filepath.Join(os.Getenv("LOCALAPPDATA"), "Packages", "Microsoft.MinecraftUWP_8wekyb3d8bbwe", "LocalState", "games", "com.mojang")
if _, err := os.Stat(result); err != nil {
if os.IsNotExist(err) {
return "", WrapErrorf(err, "Failed to find file %s", result)
return "", WrapErrorf(err, "Failed to find com.mojang path at '%s'. Does your system have multiple user accounts?", result)
}
return "", WrapErrorf(err, "Failed to access stats of %s", result)
return "", WrapErrorf(err, "Something went wrong accessing '%s'. Are your user permissions correct?", result)
}
return result, nil
}

0 comments on commit 4578f0f

Please sign in to comment.