"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Controllers/errors.html" (14 Sep 2022, 60557 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)



An instance of the Spring Errors interface containing errors associated with this controller.


class DemoController {

    static allowedMethods = [updatePerson: 'PUT']

    def generateReport(int size) {
        if(hasErrors()) {
            errors.allErrors.each {
                println it

    def updatePerson(SomeDomainClass sdc) {
        // if params.id is found then a call
        // will have been made to SomeDomainClass.get(params.id)
        // to retrieve the instance from the database.
        // if no matching instance is found then
        // sdc will be null and the controller
        // will not have errors.  If params.id
        // is found and an exception occurs while
        // trying to retrieve the instance then
        // sdc will be null and an error will
        // be added to the controller
        if(sdc == null && hasErrors()) {
            errors.allErrors.each {
                println it


The errors property is used by Grails while processing a request. Errors are generated when a type conversion happens while processing action parameters or if an exception is thrown while trying to retrieve a domain class command object from the database.

See hasErrors.