Mercurial Hosting > luan
comparison core/src/luan/modules/PackageLuan.java @ 646:cdc70de628b5
simplify LuanException
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2016 19:58:39 -0600 |
parents | 859c0dedc8b6 |
children | ca169567ce07 |
comparison
equal
deleted
inserted
replaced
645:859c0dedc8b6 | 646:cdc70de628b5 |
---|---|
32 } | 32 } |
33 | 33 |
34 public static Object require(LuanState luan,String modName) throws LuanException { | 34 public static Object require(LuanState luan,String modName) throws LuanException { |
35 Object mod = load(luan,modName); | 35 Object mod = load(luan,modName); |
36 if( mod==null ) | 36 if( mod==null ) |
37 throw new LuanException(luan, "module '"+modName+"' not found" ); | 37 throw new LuanException( "module '"+modName+"' not found" ); |
38 return mod; | 38 return mod; |
39 } | 39 } |
40 | 40 |
41 public static Object load(LuanState luan,String modName) throws LuanException { | 41 public static Object load(LuanState luan,String modName) throws LuanException { |
42 LuanTable loaded = loaded(luan); | 42 LuanTable loaded = loaded(luan); |
54 ); | 54 ); |
55 if( mod == null ) { | 55 if( mod == null ) { |
56 mod = loaded.rawGet(modName); | 56 mod = loaded.rawGet(modName); |
57 if( mod != null ) | 57 if( mod != null ) |
58 return mod; | 58 return mod; |
59 throw new LuanException(luan, "module '"+modName+"' returned nil" ); | 59 throw new LuanException( "module '"+modName+"' returned nil" ); |
60 } | 60 } |
61 } | 61 } |
62 loaded.rawPut(modName,mod); | 62 loaded.rawPut(modName,mod); |
63 } | 63 } |
64 return mod; | 64 return mod; |