Skip to content

Python import errors are ugly #1307

@sgammon

Description

@sgammon

Expected Behavior

When importing a module that doesn't exist, there is a nasty stacktrace.

Actual Behaviour

It should be prettier

Stacktrace

ModuleNotFoundError: No module named 'random'
        at org.graalvm.polyglot/org.graalvm.polyglot.Value.throwException(Value.java:1887)
        at elide.tool.cli.cmd.repl.ToolShellCommand.processUserCodeError(ToolShellCommand.kt:920)
        at elide.tool.cli.cmd.repl.ToolShellCommand.beginInteractiveSession$lambda$23$lambda$22(ToolShellCommand.kt:1032)
        at elide.tool.cli.cmd.repl.ToolShellCommand.initCLI(ToolShellCommand.kt:561)
        at elide.tool.cli.cmd.repl.ToolShellCommand.beginInteractiveSession(ToolShellCommand.kt:981)
        at elide.tool.cli.cmd.repl.ToolShellCommand.invoke$lambda$72$lambda$71(ToolShellCommand.kt:1568)
        at elide.tool.cli.AbstractSubcommand.withDeferredContext(AbstractSubcommand.kt:569)
        at elide.tool.cli.cmd.repl.ToolShellCommand.invoke(ToolShellCommand.kt:1536)
        at elide.tool.cli.cmd.repl.ToolShellCommand$invoke$1.invokeSuspend(ToolShellCommand.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:47)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at elide.tool.cli.AbstractToolCommand.call(AbstractToolCommand.kt:292)
        at elide.tool.cli.Elide.invoke-AZeniH0(Elide.kt:393)
        at elide.tool.cli.AbstractToolCommand$call$$inlined$execute$1.invokeSuspend(AbstractToolCommand.kt:185)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:47)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at elide.tool.cli.AbstractToolCommand.call(AbstractToolCommand.kt:292)
        at elide.tool.cli.AbstractToolCommand.call(AbstractToolCommand.kt:55)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
        at picocli.CommandLine.execute(CommandLine.java:2174)
        at elide.tool.cli.Elide$Companion.entry(Elide.kt:446)
        at elide.tool.cli.MainKt.main(main.kt:239)
        at java.base@23.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

Steps To Reproduce

  1. Run Python at beta1 with elide python
  2. import random

Environment Information

  • Operating System: All
  • Architecture: All

Runtime

Native

Language

Python

Example Application

No response

Version

1.0.0-beta1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions