Modify

Ticket #191 (closed enhancement: fixed)

Opened 3 years ago

Last modified 19 months ago

provide fallback in case variable loading faces 40x

Reported by: mpo Owned by: mpo
Priority: minor Milestone: 0.4
Component: modules/kauri-template Version: trunk
Keywords: Cc:

Description

The construct:

  <t:variable src="module:/path/something.json" />

currently fails the complete template if the path cannot be found.

It would be nice if it could be more silent about this and made to fallback to some default or 'undefined/null' value for further testing in the template.

Attachments

patch_191.txt (5.0 KB) - added by mpo 2 years ago.
attempt to implement this feature

Change History

comment:1 Changed 2 years ago by mpo

some relation to #41

comment:2 Changed 2 years ago by mpo

Proposal:

  • foresee a @fallback expression that can produce a default value in case the src load fails
  • resort to exception throwing like today if src fails and no @fallback is given

Work to be done VariableBlock?.java in universe/kauri-template

Changed 2 years ago by mpo

attempt to implement this feature

comment:3 Changed 2 years ago by mpo

Just added a patch implementing this without introducing a new attribute.

Looking at the code I had the impression we could just let @src overwrite what @value or the nested block where doing already. This patch does that:

  1. first expand the @value or interpret the nested block if no @value was present
  2. then allow that 'fallback' be overwritten by loading data from @src
  3. only throw an exception if still no data is returned

Didn't find any tests conflicting with this new behaviour, but the patch includes an extension of the tests to check for the new approach.

Haven't committed straight on 'cause I wanted to give you some time for feedback.

comment:4 Changed 2 years ago by mpo

Committed the patch after discussion with Jeroen in r1436.
TODO: add documentation (waiting to close the ticket)

comment:5 Changed 20 months ago by freya

  • Owner changed from jgou to mpo
  • Status changed from new to assigned

comment:6 Changed 19 months ago by mpo

  • Status changed from assigned to closed
  • Resolution set to fixed
View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.