diff --git a/system/ioc/dsl/ColdBoxDSL.cfc b/system/ioc/dsl/ColdBoxDSL.cfc index cf8d67c61..450231c4a 100644 --- a/system/ioc/dsl/ColdBoxDSL.cfc +++ b/system/ioc/dsl/ColdBoxDSL.cfc @@ -175,27 +175,34 @@ component accessors="true" { // module setting? if ( find( "@", thisLocationKey ) ) { moduleSettings = variables.coldbox.getSetting( "modules" ); - if ( - structKeyExists( moduleSettings, listLast( thisLocationKey, "@" ) ) - and structKeyExists( - moduleSettings[ listLast( thisLocationKey, "@" ) ], - "settings" - ) - and structKeyExists( - moduleSettings[ listLast( thisLocationKey, "@" ) ].settings, - listFirst( thisLocationKey, "@" ) - ) - ) { - return moduleSettings[ listLast( thisLocationKey, "@" ) ].settings[ - listFirst( thisLocationKey, "@" ) - ]; - } else { + var moduleName = listLast( thisLocationKey, "@" ); + if ( !structKeyExists( moduleSettings, moduleName ) ) { + throw( + type = "ColdBoxDSL.InvalidDSL", + message = "The DSL provided was not valid: #arguments.definition.toString()#", + detail = "The module requested: #moduleName# does not exist in the loaded modules. Loaded modules are #structKeyList( moduleSettings )#" + ); + } + + if ( !structKeyExists( moduleSettings[ moduleName ], "settings" ) ) { throw( type = "ColdBoxDSL.InvalidDSL", message = "The DSL provided was not valid: #arguments.definition.toString()#", - detail = "The module requested: #listLast( thisLocationKey, "@" )# does not exist in the loaded modules. Loaded modules are #structKeyList( moduleSettings )#" + detail = "The module requested: #moduleName# does not have any settings defined." ); } + + var settingName = listFirst( thisLocationKey, "@" ) + + if ( !structKeyExists( moduleSettings[ moduleName ].settings, settingName ) ) { + throw( + type = "ColdBoxDSL.InvalidDSL", + message = "The DSL provided was not valid: #arguments.definition.toString()#", + detail = "The module requested: #moduleName# does not have the setting [#settingName#] defined. Available settings are: [#moduleSettings[ moduleName ].settings.keyList( ", " )#]" + ); + } + + return moduleSettings[ moduleName ].settings[ settingName ]; } // just get setting return variables.coldbox.getSetting( thisLocationKey ); diff --git a/tests/specs/ioc/dsl/ColdBoxDSLTest.cfc b/tests/specs/ioc/dsl/ColdBoxDSLTest.cfc index fe2366320..69094002a 100755 --- a/tests/specs/ioc/dsl/ColdBoxDSLTest.cfc +++ b/tests/specs/ioc/dsl/ColdBoxDSLTest.cfc @@ -1,5 +1,5 @@ - - +component extends="coldbox.system.testing.BaseModelTest" { + function setup(){ mockLogger = createEmptyMock( "coldbox.system.logging.Logger" ) .$( "canDebug", true ) @@ -184,5 +184,5 @@ c = builder.getColdBoxDSL( def ); assertEquals( this, c ); } - - + +}