Include variable value when throwing exception

1 Ansicht (letzte 30 Tage)
Jurgen vL
Jurgen vL am 21 Mai 2019
Kommentiert: Marc Youcef am 22 Mär. 2020
I have a function that throws a specific exception, and a try/catch block in a top-level function that handles it. I want to pass along the value of some variables in addition to the error message for debugging purposes. Typically cell array, string array or numerical matrix.
I'm guessing I would have to create a custom exception class for this?
Follow-up: Why is the default MException so restrictive? Is error handling like I described a bad practice?
  1 Kommentar
Marc Youcef
Marc Youcef am 22 Mär. 2020
I was looking for same thing as well. I hav objects being instantiated in a loop and when it fails I would like to know which index of instantiation failed.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Variables finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by