Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make eutil:getPreference#2 and edition:getPreferencesURI#1 more robust #428

Merged
merged 5 commits into from
Sep 12, 2024

Conversation

peterstadler
Copy link
Member

@peterstadler peterstadler commented Sep 12, 2024

Description, Context and related Issue

The function eutil:getPreference#2 has an optional parameter $edition but is calling edition:getPreferencesURI($edition) where the function parameter is not optional but required.
So, if eutil:getPreference#2 is called with an empty $edition parameter an error is thrown by edition:getPreferencesURI#1:

javax.servlet.ServletException: javax.servlet.ServletException: An error occurred while processing request to /index.html: exerr:ERROR The actual return type does not match the sequence type declared in the function's signature: edition:getPreferencesURI(xs:string) xs:string. Expected cardinality: exactly one, got 0. [at line 93, column 43, source: /db/apps/Edirom-Online/data/xqm/util.xqm]

I separated out the various steps into four commits and added (hopefully) appropriate documentation to the individual commits.

How Has This Been Tested?

Tested locally

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation Update

Checklist

  • I have updated the documentation accordingly.
  • I have performed a self-review of my code
  • I have read the CONTRIBUTING document.

the parameter `$uri` is optional now. If `$uri` is empty or no reference to preferences is found the fallback `$edition:default-prefs-location` will be returned
* improvements to documentation
* wrap a try/catch block around the doc-function for more robustness since the doc-function will fail for non-existent URIs
* simplify the lookup. There's no need for the fallback to "edirom-prefs.xml" since this is already done by `edition:getPreferencesURI#1`
@peterstadler peterstadler added Type: bugfix A pull request providing a bugfix Area: XQuery labels Sep 12, 2024
@peterstadler peterstadler added this to the 1.0.0 milestone Sep 12, 2024
bwbohl
bwbohl previously approved these changes Sep 12, 2024
Copy link
Member

@bwbohl bwbohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for your great improvement

add/data/xql/getPreferences.xql Outdated Show resolved Hide resolved
@bwbohl bwbohl merged commit 95a76e8 into develop Sep 12, 2024
1 check passed
@bwbohl bwbohl deleted the fix/getPreferencesURI branch September 12, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: XQuery Type: bugfix A pull request providing a bugfix
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants