Skip to content

Predefined error messages#95

Merged
da-h merged 3 commits intomasterfrom
predefined_error_messages
Nov 16, 2021
Merged

Predefined error messages#95
da-h merged 3 commits intomasterfrom
predefined_error_messages

Conversation

@da-h
Copy link
Copy Markdown
Owner

@da-h da-h commented Nov 16, 2021

Add Error Message to Required Variables

This MR allows the module-creator to give the user more information about a set of required variables (if they are missing).

Description

Reason for this change is that miniflask allows module-groups to be entangled, in a way that require a module of one group to be loaded in order for another module to be working.
For instance, imagine a module to be a template or base-class for other instanciations that set the base variables according to their specialized features.

This MR gives the possibility to remind the user in such cases that there is such an dependency and the user requires to choose a specialization.

Previously:
The user would get a list of all required parameters, possibly not remembering or knowing about the inter-connection of some modules.

New Behavior:
Additionally, the user gets a message to describe the unmet dependencies.

Things done in this MR

  • added an option to mf.register_defaults(..., missing_argument_message=None)

Check all before creating this PR:

  • Documentation adapted
  • unit tests adapted / created

Example Usage

def register(mf):
    mf.register_default({'somevariable', int}, missing_argument_message="Did you forget to load a module to specialize this base-module?")

@da-h da-h force-pushed the predefined_error_messages branch from 09f4494 to 16d084f Compare November 16, 2021 13:08
@da-h da-h force-pushed the predefined_error_messages branch from 16d084f to ee6a2e2 Compare November 16, 2021 13:10
@da-h da-h merged commit 8cd4655 into master Nov 16, 2021
github-actions Bot pushed a commit that referenced this pull request Nov 16, 2021
@sbrodehl sbrodehl deleted the predefined_error_messages branch October 7, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant