mirror of
https://github.com/apple/pkl.git
synced 2026-05-28 01:29:15 +02:00
Improve handling of errors when analysis fails (#948)
Modules that cannot be loaded for one reason or another now cause a Pkl Exception, with the offending import highlighted as part of the stack trace.
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
import "bogusModule.pkl"
|
||||
+1
@@ -0,0 +1 @@
|
||||
import* ".../**.pkl"
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import "pkl:analyze"
|
||||
import "pkl:reflect"
|
||||
import ".../input-helper/analyze/cannotFindModule.pkl"
|
||||
|
||||
res = analyze.importGraph(Set(reflect.Module(cannotFindModule).uri))
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import "pkl:analyze"
|
||||
import "pkl:reflect"
|
||||
import ".../input-helper/analyze/invalidGlob.pkl"
|
||||
|
||||
res = analyze.importGraph(Set(reflect.Module(invalidGlob).uri))
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
–– Pkl Error ––
|
||||
Cannot find module `bogusModule.pkl`.
|
||||
|
||||
x | import "bogusModule.pkl"
|
||||
^^^^^^^^^^^^^^^^^
|
||||
at pkl.analyze#importGraph (file:///$snippetsDir/input-helper/analyze/cannotFindModule.pkl)
|
||||
|
||||
x | res = analyze.importGraph(Set(reflect.Module(cannotFindModule).uri))
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at analyzeImportsCannotFindModule#res (file:///$snippetsDir/input/errors/analyzeImportsCannotFindModule.pkl)
|
||||
|
||||
xxx | text = renderer.renderDocument(value)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at pkl.base#Module.output.text (pkl:base)
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
–– Pkl Error ––
|
||||
Cannot combine glob imports with triple-dot module URIs.
|
||||
|
||||
x | import* ".../**.pkl"
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
at analyzeImportsInvalidGlob#invalidGlob (file:///$snippetsDir/input-helper/analyze/invalidGlob.pkl)
|
||||
|
||||
x | res = analyze.importGraph(Set(reflect.Module(invalidGlob).uri))
|
||||
^^^^^^^^^^^
|
||||
at analyzeImportsInvalidGlob#res (file:///$snippetsDir/input/errors/analyzeImportsInvalidGlob.pkl)
|
||||
|
||||
xxx | text = renderer.renderDocument(value)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
at pkl.base#Module.output.text (pkl:base)
|
||||
Reference in New Issue
Block a user