diff --git a/src/bindx/Bind.hx b/src/bindx/Bind.hx index 2d65cfb..4eec159 100644 --- a/src/bindx/Bind.hx +++ b/src/bindx/Bind.hx @@ -1,7 +1,7 @@ package bindx; #if macro -import bindx.Error; +import bindx.GenericError; import haxe.macro.Expr; import haxe.macro.Type; import haxe.macro.Context; @@ -68,14 +68,14 @@ class Bind { if (res.error != null) res.error.contextError(); } catch (e:FatalError) { e.contextFatal(); - } catch (e:bindx.Error) { + } catch (e:GenericError) { e.contextError(); }; return res; } - static function checkField(f:Expr):{e:Expr, field:ClassField, error:bindx.Error} { - var error:bindx.Error; + static function checkField(f:Expr):{e:Expr, field:ClassField, error:GenericError} { + var error:GenericError; switch (f.expr) { case EField(e, field): var type = Context.typeof(e); @@ -85,7 +85,7 @@ class Bind { return {e:f, field:null, error:error}; } if (!isBindable(classType)) { - error = new bindx.Error('\'${e.toString()}\' must be bindx.IBindable', e.pos); + error = new GenericError('\'${e.toString()}\' must be bindx.IBindable', e.pos); } var field:ClassField = classType.findField(field, null); @@ -95,17 +95,17 @@ class Bind { } if (!field.hasBindableMeta()) { - error = new bindx.Error('\'${e.toString()}.${field.name}\' is not bindable', field.pos); + error = new GenericError('\'${e.toString()}.${field.name}\' is not bindable', field.pos); } return {e:e, field:field, error:error}; case EConst(CIdent(_)): - return {e:f, field:null, error:new bindx.Error('Can\'t bind \'${f.toString()}\'. Please use \'this.${f.toString()}\'', f.pos)}; + return {e:f, field:null, error:new GenericError('Can\'t bind \'${f.toString()}\'. Please use \'this.${f.toString()}\'', f.pos)}; case _: } - return {e:f, field:null, error:new bindx.Error('\'${f.toString()}\' is not bindable', f.pos)}; + return {e:f, field:null, error:new GenericError('\'${f.toString()}\' is not bindable', f.pos)}; } static function isBindable(classType:ClassType):Bool { diff --git a/src/bindx/BindExt.hx b/src/bindx/BindExt.hx index 2475c9e..85d758b 100644 --- a/src/bindx/BindExt.hx +++ b/src/bindx/BindExt.hx @@ -2,7 +2,7 @@ package bindx; #if macro -import bindx.Error; +import bindx.GenericError; import haxe.macro.Expr; import haxe.macro.MacroStringTools; import haxe.macro.Type; @@ -55,7 +55,7 @@ class BindExt { static function internalBindChain(expr:Expr, listener:Expr):Expr { var zeroListener = listenerName(0, ""); var chain = null; - try { chain = warnPrepareChain(expr, macro $i{ zeroListener }); } catch (e:bindx.Error) e.contextError(); + try { chain = warnPrepareChain(expr, macro $i{ zeroListener }); } catch (e:GenericError) e.contextError(); return macro (function ($zeroListener):Void->Void $b { chain.init.concat(chain.bind).concat([macro return function ():Void $b { chain.unbind }]) } @@ -108,7 +108,7 @@ class BindExt { var c = null; try { c = warnPrepareChain(expr, macro $i { zeroListener }, pre, true); - } catch (e:bindx.Error) { + } catch (e:GenericError) { Warn.w('${expr.toString()} is not bindable.', e.pos, WarnPriority.ALL); } if (c != null) { @@ -227,7 +227,7 @@ class BindExt { } var bindableNum = fields.fold(function (it, n) return n += it.bindable ? 1 : 0, 0); if (bindableNum == 0) { - throw new bindx.Error('${expr.toString()} is not bindable.', expr.pos); + throw new GenericError('${expr.toString()} is not bindable.', expr.pos); return null; } if (first != null) @@ -315,7 +315,7 @@ class BindExt { } if (zeroListener == null || zeroListener.f.bindable == false) - throw new bindx.Error('${expr.toString()} is not bindable.', expr.pos); + throw new GenericError('${expr.toString()} is not bindable.', expr.pos); var zeroName = zeroListener.f.e.toString(); if (zeroName != "this") diff --git a/src/bindx/BindMacros.hx b/src/bindx/BindMacros.hx index f030f77..3007d78 100644 --- a/src/bindx/BindMacros.hx +++ b/src/bindx/BindMacros.hx @@ -1,6 +1,6 @@ package bindx; -import bindx.Error; +import bindx.GenericError; import haxe.macro.Type; import haxe.macro.Expr; import haxe.macro.Context; diff --git a/src/bindx/Error.hx b/src/bindx/GenericError.hx similarity index 94% rename from src/bindx/Error.hx rename to src/bindx/GenericError.hx index 1137b66..90b9697 100644 --- a/src/bindx/Error.hx +++ b/src/bindx/GenericError.hx @@ -23,9 +23,9 @@ class Warn { } } -class FatalError extends Error {} +class FatalError extends GenericError {} -class Error { +class GenericError { public var pos(default, null):Position; public var message(default, null):String;