Skip to content

Commit

Permalink
Errors refact
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancisBourre committed Jan 22, 2019
1 parent a3d3fd6 commit be577bd
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 113 deletions.
2 changes: 1 addition & 1 deletion src/hex/collection/ArrayMap.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hex.collection;

import hex.collection.IHashMap;
import hex.error.NullPointerException;
import hex.util.ArrayUtil;
using hex.error.Error;

/**
* ...
Expand Down
2 changes: 1 addition & 1 deletion src/hex/collection/HashMap.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package hex.collection;

import hex.core.HashCodeFactory;
import hex.error.NullPointerException;
using hex.error.Error;

/**
* ...
Expand Down
6 changes: 4 additions & 2 deletions src/hex/collection/Locator.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package hex.collection;

using hex.error.Error;

/**
* ...
* @author Francis Bourre
Expand Down Expand Up @@ -43,7 +45,7 @@ class Locator<KeyType, ValueType>
}
else
{
throw new hex.error.NoSuchElementException( "Can't find item with '" + key + "' key" );
throw new NoSuchElementException( "Can't find item with '" + key + "' key" );
}
}

Expand All @@ -61,7 +63,7 @@ class Locator<KeyType, ValueType>
{
if ( this._map.containsKey( key ) )
{
throw new hex.error.IllegalArgumentException( "item is already registered with '" + key + "' key" );
throw new IllegalArgumentException( "item is already registered with '" + key + "' key" );
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/hex/core/HashCodeFactory.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hex.core;

import hex.error.PrivateConstructorException;
using hex.error.Error;

/**
* ...
Expand Down
46 changes: 46 additions & 0 deletions src/hex/error/Error.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package hex.error;

import haxe.PosInfos;
using tink.CoreApi;

@IgnoreCover
class IllegalArgumentException extends Error
{
public function new ( message : String, ?posInfos : PosInfos ) super( code, message, pos );
}

@IgnoreCover
class IllegalStateException extends Error
{
public function new ( message : String, ?posInfos : PosInfos ) super( code, message, pos );
}

@IgnoreCover
class NoSuchElementException extends Error
{
public function new ( message : String, ?posInfos : PosInfos ) super( code, message, pos );
}

@IgnoreCover
class NullPointerException extends Error
{
public function new ( message : String, ?posInfos : PosInfos ) super( code, message, pos );
}

@IgnoreCover
class PrivateConstructorException extends Error
{
public function new ( ?message : String = "This class can't be instantiated.", ?posInfos : PosInfos ) super( code, message, pos );
}

@IgnoreCover
class UnsupportedOperationException extends Error
{
public function new ( message : String, ?posInfos : PosInfos ) super( code, message, pos );
}

@IgnoreCover
class VirtualMethodException extends Error
{
public function new ( ?message : String = 'this method must be overridden', ?posInfos : PosInfos ) super( code, message, pos );
}
14 changes: 0 additions & 14 deletions src/hex/error/IllegalArgumentException.hx

This file was deleted.

14 changes: 0 additions & 14 deletions src/hex/error/IllegalStateException.hx

This file was deleted.

14 changes: 0 additions & 14 deletions src/hex/error/NoSuchElementException.hx

This file was deleted.

14 changes: 0 additions & 14 deletions src/hex/error/NullPointerException.hx

This file was deleted.

14 changes: 0 additions & 14 deletions src/hex/error/PrivateConstructorException.hx

This file was deleted.

14 changes: 0 additions & 14 deletions src/hex/error/UnsupportedOperationException.hx

This file was deleted.

14 changes: 0 additions & 14 deletions src/hex/error/VirtualMethodException.hx

This file was deleted.

2 changes: 1 addition & 1 deletion src/hex/event/TriggerBuilder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import haxe.macro.Type.ClassType;
import haxe.macro.Type.Ref;
import haxe.macro.Type.TypeParameter;
import haxe.macro.TypeTools;
import hex.error.PrivateConstructorException;
import hex.event.ITrigger;
import hex.util.MacroUtil;

using haxe.macro.Context;
using haxe.macro.Tools;
using tink.MacroApi;
using hex.error.Error;

/**
* ...
Expand Down
2 changes: 1 addition & 1 deletion src/hex/util/ArrayUtil.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package hex.util;

import hex.error.PrivateConstructorException;
using hex.error.Error;

/**
* ...
Expand Down
9 changes: 2 additions & 7 deletions src/hex/util/ClassUtil.hx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package hex.util;

import hex.error.IllegalArgumentException;
import hex.error.PrivateConstructorException;
using hex.error.Error;

/**
* ...
* @author Francis Bourre
*/
class ClassUtil
{
/** @private */
function new()
{
throw new PrivateConstructorException();
}
/** @private */ function new() throw new PrivateConstructorException();

static public function getInheritanceChain( clazz : Class<Dynamic> ) : Array<Class<Dynamic>>
{
Expand Down
3 changes: 2 additions & 1 deletion src/hex/util/MacroUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import haxe.macro.Expr.TypePath;
import haxe.macro.ExprTools;
import haxe.macro.Type.ClassType;
import haxe.macro.TypeTools;
using hex.error.Error;

using Lambda;

Expand All @@ -17,7 +18,7 @@ using Lambda;
*/
class MacroUtil
{
/** @private */ function new() throw new hex.error.PrivateConstructorException();
/** @private */ function new() throw new PrivateConstructorException();

macro public static function classImplementsInterface( classRef : haxe.macro.Expr.ExprOf<String>, interfaceRef : haxe.macro.Expr.ExprOf<String> ) : Expr
{
Expand Down

0 comments on commit be577bd

Please sign in to comment.