Return to Snippet

Revision: 10490
at January 2, 2009 11:00 by callmeblessed


Initial Code
// in controller/services :
class GrailsService { 
    boolean transactional = true
    def messageSource ; 
    
    def locale = Locale.getDefault()
  domainObj.errors.each { fieldErrors ->
     fieldErrors.allErrors.each { error ->
        log.warn messageSource.getMessage(error, locale)
     }
  }

}

Initial URL


Initial Description
how to read error message as string instead of complicated codes. usually people using taglib to read error messages. but how to read it in controller/service if you, for example, want to log or render just the message. here is how to do that.

Initial Title
Grails : How to read error without using g:view (in controller / service)

Initial Tags
error, groovy

Initial Language
Groovy