Catch errors when applying parameters (Session API-V3)

How can I catch error on this method : getParameterByName() ?
Using now:
session.getParameterByName(param_name) = param_value
Working. And displaying errors on browser console log like this:
I would like to catch errors to post them in an external log.
.catch((e) => {} isn’t working here …
Thanks for helping!

Maybe with isValid() Method ? How ?

Solved: :grinning:

// read out the parameter with the specific name
var currentParameter = session.getParameterByName(param_name)[0]

// check if value is valid for this parameter
try {
  currentParameter.isValid(param_value, true)
  // valid > apply value
  currentParameter.value = param_value 
catch(err) {
  console.log('Value "'+param_value +'" for parameter "'+param_name+'" is not valid')
  console.log('Details: '+err)

Exportable Log: