question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception thrown for Option Conversion Functions

See original GitHub issue

If an Option Conversion Function is used and the validation fails, a warning is thrown as expected. For example,

invalid option value: (option: "relates"; value: '')
invalid literal for int() with base 10: ''.

This is however followed by an exception.

Extension error (sphinxcontrib.needs.directives.need):
Handler <function process_need_nodes at 0x7fc72d597ee0> for event 'doctree-resolved' threw an exception (exception: '{need_id}')

How to reproduce

In conf.py create

needs_extra_options = {
"link": directives.nonnegative_int
}

Create a need with

.. need::
   :id: my_need_id
   :link: hugo

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danwoscommented, May 3, 2021

No, your way is the correct one. Layout & Style feature cares about the final representation (e.g. showing a link instead of a normal string).

Right now there is no way in Sphinx-Needs to modify an option value, when it gets read in. And I’m not sure if there is a real use case for it, because this would then affected also filter-string and the representation in tables and co. (e.g. given ‘259’ for option `related-link*, should be stored as 'my-server.com/259).

Maybe there is a way to skip creating an extra data element and a dynamic function. You used it to calculate the link target url only. If this calculation could be done in the layout, you would only need the relates field and store the number.

One solution could be to use your own idea, before you switched to using <<link()>> 😃 :

`<<meta("relates")>> <https://github.com/useblocks/sphinxcontrib-needs/issues/\<\<meta("relates")\>\>>`_

Another one to enhance the link() function to use placeholders in the url part:

<<link(""https://github.com/useblocks/sphinxcontrib-needs/issues/[[relates]]"), "link", is_dynamic=False)>>

If we touch the <<link()>> function, we maybe should also think about supporting lists of values. E.g. relates could contain 3 ids like 259,341; 231 and the need should show 3 related links.

0reactions
twodropscommented, Oct 6, 2021

I guess we discussed too many unrelated issues here. The original issue could probably be rejected, as such a usage will anyway affect incremental build. https://sphinxcontrib-needs.readthedocs.io/en/latest/configuration.html#incremental-build-support

The hint on Option Conversion Function here https://sphinxcontrib-needs.readthedocs.io/en/latest/configuration.html#needs-extra-options could be removed as well as it was confusing and made me feel that Option Conversion Function could be used in this way.

The future enhancement related to link could be a separate issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

boost::program_option::store throws exception when option ...
actually works fine, it is the boost::program_options::store() function that fails to convert string in utf-8 back to wstring.
Read more >
C++ Exceptions Support - Emscripten
This option leverages a new feature that brings built-in instructions for throwing and catching exceptions to WebAssembly. As a result, it can reduce...
Read more >
Functional Exceptions In Java - 8th Light
So, what happens when an exception-throwing method is called in a lambda? ... use Optional to convert the nullable return value into a...
Read more >
Exception Clause - Apache Camel
You can use the Exception Clause in the Java DSL to specify the error handling you require on a per exception type basis...
Read more >
4 Errors and Exception Handling
An exception is a PL/SQL error that is raised during program execution, either implicitly by TimesTen or explicitly by your program. Handle an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found