ColdBox SEEK 4.1.0+00002 Gideon

Hi, I’m migrating an application from ColdBox 3.8 to Coldbox 4, running on ColdFusion 9.01, and in some handler I have the onError event.
When I run any Handler that contains this onError event, I get an error “CFCATCH is undefined”.

I found that in coldbox.system.web.Controller in the function _runEvent is this block of code

} catch( any e ){
if( oHandler._actionExists( “onError” ) ){
loc.results = oHandler.onError(
event = oRequestContext,
rc = args.rc,
prc = args.prc,
faultAction = ehBean.getmethod(),
exception = cfcatch,
eventArguments = arguments.eventArguments);
} else {
rethrow;
}
}

On line 632 is “exception = cfcatch” so I changed it for "exception = e ", and that solved the issue.

} catch( any e ){
if( oHandler._actionExists( “onError” ) ){
loc.results = oHandler.onError(
event = oRequestContext,
rc = args.rc,
prc = args.prc,
faultAction = ehBean.getmethod(),
exception = e,
eventArguments = arguments.eventArguments);
} else {
rethrow;
}
}

I hope this can help, thanks.

Angel Torres.

Thanks Angel. I put in this ticket:
https://ortussolutions.atlassian.net/browse/COLDBOX-441

Do you feel brave enough to submit a pull request to our development branch? :slight_smile:

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Your welcome,
I feel brave enough, unfortunately I don’t know how to do it, if you point me in some direction to learn that I will gladly help :).

I found another issue, this time is in modules.cborm.models.validations.uniqueValidator
I have this Entity with constraints.

`
component persistent=“true” table=“users” {

property name=“id” column=“id” fieldtype=“id” generator=“native” setter=“false”;
property name=“username” ormtype=“string”;
property name=“name” ormtype=“string”;

this.constraints = { ‘username’ = { required = true, validator = ‘cbORM.models.validation.uniqueValidator’}
,name = { required = true }

};

User function init(){

return this;

}

}
`

Then I validate it with this code

}var User = ORMService.new( 'User' ); User.setUsername( 'admin' ); User.setName( 'MyName' ); var vResults = validateModel( User );

I get the following error:

Type: expression
Messages: Can’t cast String [cbORM.models.validation.uniqueValidator] to a boolean

So in the validator is this code in line 36:

`
// return true if not unique, nothing needed to check

if( !arguments.validationData ){ return true; }
`

The validator takes as argument for validationData the path to the validator cbORM.models.validation.uniqueValidator, and I guess the error es because this is a string and not a boolean and the expression !arguments.validationData can’t be evaluated.

Then if I remove or comment this line

//if( !arguments.validationData ){ return true; }

In ACF everything goes fine and the Entity is validated.

Thanks.

That’s seems like a bug. I will verify.

Verified and squashed. update the module:

box update cborm

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org

ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

Thanks, I found another issue with the uniqueValidator.cfc.
If you want a custom message for this validator, the constraint should be for example:

"RFC" = { validator = "cborm.models.validation.uniqueValidator", validatorMessage = "El RFC del cónyuge no es único en la base de datos" }

var args = {message="The '#arguments.field#' value '#arguments.targetValue#' is not unique in the database",field=arguments.field,validationType=getName(),validationData=arguments.validationData};

But when you validate the entity the message obtained is the default one The ‘#arguments.field#’ value ‘#arguments.targetValue#’ is not unique in the database.

Here the validationType to instantiate the error is “unique” which is the value of the name property for this validator. Then the validationResult checks if there is a key named #error.getValidationType()#Message which result in “uniqueMessage”, that key does not exist as the one declared was “validatorMessage”, so this condition is false and the default message is not replaced in globalReplacements().
To make it work, I replaced the getName() on the validationType argument with ‘validator’, so the validationResult will seek for “validatorMessage” and now that key does exist.