comparison core/src/luan/LuanState.java @ 646:cdc70de628b5

simplify LuanException
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Mar 2016 19:58:39 -0600
parents 859c0dedc8b6
children 8e8c30b72e9b
comparison
equal deleted inserted replaced
645:859c0dedc8b6 646:cdc70de628b5
63 63
64 64
65 public Boolean checkBoolean(Object obj) throws LuanException { 65 public Boolean checkBoolean(Object obj) throws LuanException {
66 if( obj instanceof Boolean ) 66 if( obj instanceof Boolean )
67 return (Boolean)obj; 67 return (Boolean)obj;
68 throw new LuanException(this, "attempt to use a " + Luan.type(obj) + " value as a boolean" ); 68 throw new LuanException("attempt to use a " + Luan.type(obj) + " value as a boolean" );
69 } 69 }
70 70
71 public String checkString(Object obj) throws LuanException { 71 public String checkString(Object obj) throws LuanException {
72 if( obj instanceof String ) 72 if( obj instanceof String )
73 return (String)obj; 73 return (String)obj;
74 throw new LuanException(this, "attempt to use a " + Luan.type(obj) + " value as a string" ); 74 throw new LuanException("attempt to use a " + Luan.type(obj) + " value as a string" );
75 } 75 }
76 76
77 public LuanFunction checkFunction(Object obj) throws LuanException { 77 public LuanFunction checkFunction(Object obj) throws LuanException {
78 if( obj instanceof LuanFunction ) 78 if( obj instanceof LuanFunction )
79 return (LuanFunction)obj; 79 return (LuanFunction)obj;
80 throw new LuanException(this, "attempt to call a " + Luan.type(obj) + " value" ); 80 throw new LuanException("attempt to call a " + Luan.type(obj) + " value" );
81 } 81 }
82 82
83 abstract public boolean isLessThan(Object o1,Object o2) throws LuanException; 83 abstract public boolean isLessThan(Object o1,Object o2) throws LuanException;
84 84
85 public String toString(Object obj) throws LuanException { 85 public String toString(Object obj) throws LuanException {
101 LuanTable tbl = (LuanTable)obj; 101 LuanTable tbl = (LuanTable)obj;
102 return tbl.get(this,key); 102 return tbl.get(this,key);
103 } 103 }
104 if( obj != null && hasJava() ) 104 if( obj != null && hasJava() )
105 return JavaLuan.__index(this,obj,key,false); 105 return JavaLuan.__index(this,obj,key,false);
106 throw new LuanException(this, "attempt to index a " + Luan.type(obj) + " value" ); 106 throw new LuanException("attempt to index a " + Luan.type(obj) + " value" );
107 } 107 }
108 108
109 /* 109 /*
110 public Number checkNumber(Object obj) throws LuanException { 110 public Number checkNumber(Object obj) throws LuanException {
111 if( obj instanceof Number ) 111 if( obj instanceof Number )