Groovy
Exception Handling
in Groovy every exception is optional. This goes for checked exceptions as well. Groovy will pass an exception to the calling code until it is handled, but we don't have to define it in our method signature. So we as developers can choose how and when to handle the exception.
Plus, @mrhaki shows us another Groovy shortcut; catch(all)
Don't be Careless With Groovy (Un)checked Exceptions
Due to the blurred difference between check and runtime exceptions in Groovy, @marcin_pil stumbled upon a bug while coding a Spring Boot application. Read his tale to understand better how to deal with exceptions in Groovy.
As the post author recommends. Write functional tests and sleep well.
Clean Code excerpt:
Checked exceptions can sometimes be useful if you are writing a critical library: You must catch them. But in general application development the dependency costs outweigh the benefits
Check if a String Only Contains Whitespaces
@mrhaki: isAllWhitespace()
What a language Groovy, always with a surprise waiting for you.
Sponsored Link
Grails ONLINE Courses Agenda
Last week, we hosted the first Grails ONLINE course. I was helping out in the course chat and I was happy to see a positive audience reaction. Moreover, It was well attended 👍. We have planned 3 new courses for the next months based on the feedback you sent us. Check them out:
- GORM Deep Dive - 50$ - Sep 7 - Sep 8
- Groovy Metaprogramming with Grails 3 - 50$ - Oct 5 - Oct 6
- Intro to Grails for Spring Developers - 50$ - Nov 2 - Nov 3
GORM
[FRENCH] Use GORM Hibernate implementation in a Groovy Script
Last week, I linked to a Grails Guide which illustrated how to use GORM with Spring Boot.
In this link, @bgoetzmann shows how to use GORM within a Groovy script thanks to Grape.
GORM everywhere 🎉🎉
Grails
Grails Database Migration Plugin Guide
Grails Guide which shows you how to use Grails Database Migration Plugin.
Using this plugin (and Liquibase in general) adds some structure and process to managing database changes. It will help avoid inconsistencies, communication issues, and other problems with ad-hoc approaches.
Gradle
Pass Java System Properties To Java Tasks
I like to annotate my Geb functional tests with:
@IgnoreIf({ !System.getProperty('geb.env') })
Learn how to pass System Properties To Java Tasks, not just integrationTest task.
Libraries
Spreadsheet Builder
Both with Java and Groovy samples. If you ever need to build an XSLX programmatically check this library first.
Spreadsheet builder provides convenient way how to read and create MS Excel OfficeOpenXML Documents (XSLX) focus not only on content side but also on easy styling.
It includes advanced features such as protection, filters, comments.
Comment
This issue is quite a cocktail🍹: Exceptions, GORM, System Properties and Gradle, Database migrations, building Spreadsheets.
A little bit for everyone. Enjoy!
Sergio del Amo