Skip to content

Commit

Permalink
fix: fix error message on importing/reading a package instead of a mo…
Browse files Browse the repository at this point in the history
…dule (#33)

* fix error messaging

* fixed a typo in import_module

* fix test
  • Loading branch information
h4ck3rk3y authored Feb 22, 2023
1 parent b86ef41 commit 1f906ae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (builtin *importModuleCapabilities) Interpret(arguments *builtin_argument.A
// Load it.
contents, interpretationError := builtin.packageContentProvider.GetModuleContents(moduleInPackage)
if interpretationError != nil {
return nil, startosis_errors.WrapWithInterpretationError(interpretationError, "An error occurred while loading the package '%v'", moduleInPackage)
return nil, startosis_errors.WrapWithInterpretationError(interpretationError, "An error occurred while loading the module '%v'", moduleInPackage)
}

globalVariables, interpretationErr := builtin.recursiveInterpret(moduleInPackage, contents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def run(plan):
_, instructions, interpretationError := interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, script, startosis_constants.EmptyInputArgs)
require.Empty(t, instructions) // No kurtosis instruction

errorMsg := `Evaluation error: An error occurred while loading the package '` + nonExistentModule + `'
errorMsg := `Evaluation error: An error occurred while loading the module '` + nonExistentModule + `'
Caused by: Package '` + nonExistentModule + `' not found`
expectedError := startosis_errors.NewInterpretationErrorWithCustomMsg(
[]startosis_errors.CallFrame{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (provider *GitPackageContentProvider) GetOnDiskAbsoluteFilePath(fileInsideP
return "", interpretationError
}
if parsedURL.relativeFilePath == "" {
return "", startosis_errors.NewInterpretationError("The relative path to file is empty for '%v'", fileInsidePackageUrl)
return "", startosis_errors.NewInterpretationError("The path '%v' needs to point to a specific file but it didn't. Users can only read or import specific files and not entire packages.", fileInsidePackageUrl)
}
pathToFile := path.Join(provider.packagesDir, parsedURL.relativeFilePath)
packagePath := path.Join(provider.packagesDir, parsedURL.relativeRepoPath)
Expand Down

0 comments on commit 1f906ae

Please sign in to comment.