11'use strict' ;
22
33var Eid = require ( '../eid' ) ;
4-
4+ var commonExConstructor = function ( eid , message ) {
5+ if ( ! ( eid instanceof Eid ) ) {
6+ eid = new Eid ( eid . toString ( ) ) ;
7+ }
8+ this . message = message !== undefined ? ( eid + " " + message ) : eid ;
9+ this . eid = eid ;
10+ }
511var EidRuntimeException = ( function ( ) {
612 /**
713 * <strong>This class shouldn't be used in any public API or library.</strong> It is designed to be used for in-house development
@@ -22,12 +28,8 @@ var EidRuntimeException = (function() {
2228 * @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2329 */
2430 function EidRuntimeException ( eid , message ) {
25- if ( ! ( eid instanceof Eid ) ) {
26- eid = new Eid ( eid . toString ( ) ) ;
27- }
2831 this . name = 'EidRuntimeException' ;
29- this . message = eid + " " + message ;
30- this . eid = eid ;
32+ commonExConstructor . apply ( this , [ eid , message ] ) ;
3133 }
3234 EidRuntimeException . prototype = new Error ( ) ;
3335 return EidRuntimeException ;
@@ -48,12 +50,8 @@ var EidNullPointerException = (function() {
4850 * @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
4951 */
5052 function EidNullPointerException ( eid , message ) {
51- if ( ! ( eid instanceof Eid ) ) {
52- eid = new Eid ( eid . toString ( ) ) ;
53- }
5453 this . name = 'EidNullPointerException' ;
55- this . message = eid + " " + message ;
56- this . eid = eid ;
54+ commonExConstructor . apply ( this , [ eid , message ] ) ;
5755 }
5856 EidNullPointerException . prototype = EidRuntimeException . prototype ;
5957 return EidNullPointerException ;
@@ -74,12 +72,8 @@ var EidIllegalArgumentException = (function() {
7472 * @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
7573 */
7674 function EidIllegalArgumentException ( eid , message ) {
77- if ( ! ( eid instanceof Eid ) ) {
78- eid = new Eid ( eid . toString ( ) ) ;
79- }
8075 this . name = 'EidIllegalArgumentException' ;
81- this . message = eid + " " + message ;
82- this . eid = eid ;
76+ commonExConstructor . apply ( this , [ eid , message ] ) ;
8377 }
8478 EidIllegalArgumentException . prototype = EidRuntimeException . prototype ;
8579 return EidIllegalArgumentException ;
@@ -100,12 +94,8 @@ var EidIllegalStateException = (function() {
10094 * @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
10195 */
10296 function EidIllegalStateException ( eid , message ) {
103- if ( ! ( eid instanceof Eid ) ) {
104- eid = new Eid ( eid . toString ( ) ) ;
105- }
10697 this . name = 'EidIllegalStateException' ;
107- this . message = eid + " " + message ;
108- this . eid = eid ;
98+ commonExConstructor . apply ( this , [ eid , message ] ) ;
10999 }
110100 EidIllegalStateException . prototype = EidRuntimeException . prototype ;
111101 return EidIllegalStateException ;
@@ -126,12 +116,8 @@ var EidIndexOfOfBoundsException = (function() {
126116 * @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
127117 */
128118 function EidIndexOfOfBoundsException ( eid , message ) {
129- if ( ! ( eid instanceof Eid ) ) {
130- eid = new Eid ( eid . toString ( ) ) ;
131- }
132119 this . name = 'EidIndexOfOfBoundsException' ;
133- this . message = eid + " " + message ;
134- this . eid = eid ;
120+ commonExConstructor . apply ( this , [ eid , message ] ) ;
135121 }
136122 EidIndexOfOfBoundsException . prototype = EidRuntimeException . prototype ;
137123 return EidIndexOfOfBoundsException ;
0 commit comments