Mercurial Hosting > luan
changeset 635:c83b8cefd922
better error handling in theme code
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 01 Mar 2016 07:01:58 -0700 |
parents | 3dde072c3420 |
children | 13b390bfed32 |
files | core/src/luan/impl/ThemeParser.java |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/core/src/luan/impl/ThemeParser.java Sun Feb 28 04:21:08 2016 -0700 +++ b/core/src/luan/impl/ThemeParser.java Tue Mar 01 07:01:58 2016 -0700 @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.ArrayList; +import luan.Luan; import luan.LuanSource; import luan.LuanTable; import luan.LuanElement; @@ -211,7 +212,10 @@ final Expr env = env(); Expr exp = new ExprImpl(se(start,"indent")) { @Override public Object eval(LuanStateImpl luan) throws LuanException { - LuanTable tbl = (LuanTable)env.eval(luan); + Object obj = env.eval(luan); + if( !(obj instanceof LuanTable) ) + throw new LuanException(luan,"bad argument (table expected, got "+Luan.type(obj)+")"); + LuanTable tbl = (LuanTable)obj; String indent = (String)tbl.get(luan,INDENT); if( indent==null ) throw new NullPointerException(); return indent;