a have a problem with my code. how can i handle an error from service to my gsp? i tried it with render from service or controller, Validation error occured during call to save(): - Field error in object 'talent.CandidateProfile' on field 'core.db_email': rejected value []; codes with full exception trace. my sources:
def create() {
[candidateProfileInstance: new CandidateProfile(params)]
}
def save() {
def candidateProfileInstance = new CandidateProfile(params)
if (!candidateProfileInstance.save(flush: true)) {
render(view: "create", model: [candidateProfileInstance: candidateProfileInstance])
return
}
flash.message = message(code: 'default.created.message', args: [message(code: 'candidateProfile.label', default: 'CandidateProfile'), candidateProfileInstance.id])
redirect(action: "show", id: candidateProfileInstance.id)
}
My .gsp page code
<div class="full-filed">
<h3>Email Address:</h3>
</div>
<div class="fieldcontain ${hasErrors(bean: candidateProfileInstance, field: 'core.db_email', 'error')} ">
<label for="core.db_email" class="error_message"> <g:message
code="candidateProfile.core.db_email.label" default="Dbemail" />
</label>
</div>
<g:textField name="core.db_email" value="" class="loginTxtBox" placeholder="Email Address" />
i want just show to user an error, but not full exception trace
form your config.grooyPage
//grails.gorm.failOnError = true
just comment to this line...SO it will display your Custom Error