+
Skip to content

Conversation

sebffischer
Copy link
Member

@sebffischer sebffischer commented Aug 11, 2025

This pull request improves errors and warnings by:

  1. Introducing proper error classes:

  2. Improving the formatting of error messages to include the error class. Because we now let the user react differently to different error classes (for now only during encapsulation), it's good to make the user familiar with the error class system. For formatting of errors, we use cli, which was already a hard dependency before.

Below are some examples for how error messages and warnings are now formatted:

mlr3misc::error_timeout()
#> Error: 
#> ✖ reached elapsed time limit
#> → Class: Mlr3ErrorTimeout
mlr3misc::error_config("Passed in regression task to classification learner")
#> Error: 
#> ✖ Passed in regression task to classification learner
#> → Class: Mlr3ErrorConfig
mlr3misc::warning_config("this was maybe wrong")
#> Warning: 
#> ✖ this was maybe wrong
#> → Class: Mlr3WarningConfig

To create the condition object, set signal = FALSE:

mlr3misc::error_timeout(signal = FALSE)
#> <Mlr3ErrorTimeout: 
#> ✖ reached elapsed time limit
#> → Class: Mlr3ErrorTimeout
#> >

TODOs:

  • what do we want to do with stopf(), warningf(), messagef()?
    --> they keep the old behavior for now. Maybe we slowly want to phase them out.
  • class starts with M
  • rename silent to signal
  • don't wrap messages in condition objects when returning them from encapsulation

Note that encapsulate() currently returns duplicate information, but this is only for the transition phase, see #142

sebffischer added a commit to mlr-org/mlr3 that referenced this pull request Aug 11, 2025
Summary:
* Depends on: mlr-org/mlr3misc#141, which
  makes `encapsulate()` also return the condition objects
* Introduce custom error/error condition constructors (#1283)
* Allows to specify for which conditions a fallback learner should
  be triggered (#1335)

TODO:
* [ ] add condition objects for warnings (varying_predict_types)
@sebffischer
Copy link
Member Author

sebffischer commented Aug 11, 2025

Should we allow to include the call?

not include it for now.

@mllg
Copy link
Member

mllg commented Aug 13, 2025

Maybe move the exported helper functions from mlr3 to misc to not polute the namespace

@sebffischer sebffischer merged commit 5400fe1 into main Aug 15, 2025
3 checks passed
@sebffischer sebffischer deleted the errors branch August 15, 2025 16:38
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.

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载