Accepting any Collection for encoding.
Catching Moodle exceptions.