Error catching imported data

Hi, I’m trying to import an optional integer via the connector (V33.5).
I’m importing the data through a provider connector using a http call which gets me an XML file. I decorate this file as a list and the specific data point as an optional text. I then walk this list and create an 'Article' entry for the interface.

In the create ( ) I have this code:

'Ideale Verpakking' = any $ .'idealeverpakking' get (
	| value as $ => create 'Bekend' (
		'Ideale Verpakking' = $ => parse as decimal || throw "Could not parse decimal"
	)
	| error => create 'Onbekend' ( )
)

However I don’t want my entire import to fail when there’s an incorrect entry. I would like for it to create 'Onbekend' ( ) if the parsing fails, however I have not been able to accomplish this. How is this possible?

I’ve tried to parse $ .'ideale verpakking' as decimal before the get to include it in the error of the get wat that did not work

You cannot parse $ .'idealeverpakking' before the get, the get is simply to step through optional and parse requires a text. As the order of the type (optional text) indicates, you have to handle optional before you get access to the text, since the text might not exist.

What you can do in the connector is chaining expressions (promise chain), see the documentation for details.

Combining this, the result would be:

any $ .'idealeverpakking' get => parse as decimal (
  ...
)

or you can switch twice when the individual results are relevant

any $ .'idealeverpakking' get (
  | value as $ => any $ => parse as decimal (
    ...
  )
  ...