better error message when (load) file isn't found
This commit is contained in:
@@ -364,7 +364,7 @@ class Kiss {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function load(kissFile:String, k:KissState, ?loadingDirectory:String, loadAllExps = false):Null<ReaderExp> {
|
public static function load(kissFile:String, k:KissState, ?loadingDirectory:String, loadAllExps = false, ?fromExp:ReaderExp):Null<ReaderExp> {
|
||||||
if (loadingDirectory == null)
|
if (loadingDirectory == null)
|
||||||
loadingDirectory = k.loadingDirectory;
|
loadingDirectory = k.loadingDirectory;
|
||||||
|
|
||||||
@@ -379,7 +379,16 @@ class Kiss {
|
|||||||
if (k.loadedFiles.exists(fullPath)) {
|
if (k.loadedFiles.exists(fullPath)) {
|
||||||
return k.loadedFiles[fullPath];
|
return k.loadedFiles[fullPath];
|
||||||
}
|
}
|
||||||
var stream = Stream.fromFile(fullPath);
|
var stream = try {
|
||||||
|
Stream.fromFile(fullPath);
|
||||||
|
} catch (m:Any) {
|
||||||
|
var message = 'Kiss file not found: $kissFile';
|
||||||
|
if (fromExp != null)
|
||||||
|
throw KissError.fromExp(fromExp, message);
|
||||||
|
Sys.println(message);
|
||||||
|
Sys.exit(1);
|
||||||
|
null;
|
||||||
|
}
|
||||||
var startPosition = stream.position();
|
var startPosition = stream.position();
|
||||||
var loadedExps = [];
|
var loadedExps = [];
|
||||||
Reader.readAndProcess(stream, k, (nextExp) -> {
|
Reader.readAndProcess(stream, k, (nextExp) -> {
|
||||||
|
@@ -50,7 +50,7 @@ class Macros {
|
|||||||
|
|
||||||
k.doc("load", 1, 1, '(load "<file.kiss>")');
|
k.doc("load", 1, 1, '(load "<file.kiss>")');
|
||||||
macros["load"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
macros["load"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
|
||||||
Kiss.load(compileTimeResolveToString("The only argument to (load...)", "a .kiss file path", args[0], k), k);
|
Kiss.load(compileTimeResolveToString("The only argument to (load...)", "a .kiss file path", args[0], k), k, null, false, wholeExp);
|
||||||
};
|
};
|
||||||
|
|
||||||
k.doc("loadFrom", 2, 2, '(loadFrom "<haxelib name>" "<file.kiss>")');
|
k.doc("loadFrom", 2, 2, '(loadFrom "<haxelib name>" "<file.kiss>")');
|
||||||
@@ -58,7 +58,7 @@ class Macros {
|
|||||||
var libName = compileTimeResolveToString("The first argument to (loadFrom...)", "a haxe library's name", args[0], k);
|
var libName = compileTimeResolveToString("The first argument to (loadFrom...)", "a haxe library's name", args[0], k);
|
||||||
var libPath = Prelude.libPath(libName);
|
var libPath = Prelude.libPath(libName);
|
||||||
var otherKissFile = compileTimeResolveToString("The second argument to (loadFrom...)", "a .kiss file path", args[1], k);
|
var otherKissFile = compileTimeResolveToString("The second argument to (loadFrom...)", "a .kiss file path", args[1], k);
|
||||||
Kiss.load(otherKissFile, k, libPath);
|
Kiss.load(otherKissFile, k, libPath, false, wholeExp);
|
||||||
};
|
};
|
||||||
|
|
||||||
function destructiveVersion(op:String, assignOp:String) {
|
function destructiveVersion(op:String, assignOp:String) {
|
||||||
|
Reference in New Issue
Block a user