R2022a problem: Line number missing in error message sent to Command Window.

With R2022a, line numbers are sometimes omitted in error messages. Here's an example using a trivial script:
If I run the same script in R2021b, here's the result:
Weird. What's going on?
Is there a way to fix this in R2022a?

5 件のコメント

Bruno Luong
Bruno Luong 2022 年 4 月 21 日
+1 I confirm I have the same issue now and then. It seems like a bug of the editor.
Scott MacKenzie
Scott MacKenzie 2022 年 4 月 21 日
@Bruno Luong, hmm, yes, I guess this is a bug (since no one has weighed in with a fix). Thanks for your comment.
Adam Danz
Adam Danz 2022 年 4 月 22 日
It looks like this only affects unrecognized table variables.
Thanks for reporting it!
Scott MacKenzie
Scott MacKenzie 2022 年 4 月 22 日
Yes, I think the problem is limited to tables. But, it goes beyond just referencing an unrecognized table variable. In the example below, the table variable exists. The error (reported without a line number) is in how the contents are accessed:
David Szwer
David Szwer 2022 年 5 月 17 日
I get this problem too; also regarding tables, but a different error.
>> ProcessAll
Error using ProcessMovement
All tables being vertically concatenated must have the same number of variables.
Error in ProcessAll (line 10)
[moving, moveN] = ProcessMovement(filedir, 0);
Note that ProcessAll and ProcessMovement are both functions. Back in the day, Matlab wouldn't show line numbers at all if the error was in a script; this isn't a reversion to that behaviour, it is something different.

サインインしてコメントする。

 採用された回答

Siddharth Bhutiya
Siddharth Bhutiya 2022 年 5 月 18 日
編集済み: Adam Danz 2023 年 10 月 16 日

6 投票

Update: this bug was fixed in R2022a update 3 and in R2022b.
------------
This is a bug, thank you for reporting it! I have passed it along and it will be fixed in a future release.
As mentioned in the bug report, while this is being fixed, you could use MException.last.stack(1) to see the line number.

10 件のコメント

Sergio Roche
Sergio Roche 2022 年 9 月 28 日
The bug report suggests to get r2022b to fix this issue, but the issue is still present in my r2022b installation.
@Sergio Roche, could you share your reproduction steps? The error message appears as expected below (R2022b). Note, if you produce the error from the command window rather than from within a function, the stack trace will not appear.
myfunc()
Error using .
Unrecognized table variable name 'Var2'.

Error in solution>myfunc (line 5)
T.Var2 % doesn't exist
function myfunc()
T = table(1);
T.Var2 % doesn't exist
end
Sergio Roche
Sergio Roche 2022 年 9 月 28 日
I am not using the table as in the example... I am raising an error using MATLAB's error function inside of a function. I expect to see the stack trace in the command window then the error is raised, but I only see the error text. Is this the expected behavior?
Scott MacKenzie
Scott MacKenzie 2022 年 9 月 28 日
The bug pertains to tables. A test using the example srcipt in my original question confirms that the bug is fixed in R2022b:
Adam Danz
Adam Danz 2022 年 9 月 28 日
@Sergio Roche, the bug report refers to errors caused by invalid indexing of tables or timetables.
If you have an error that used to show the stack trace in previous version of MATLAB and now no longer shows the stack trace, I suggest creating minimal reproduction steps and asking a new question. Include the MATLAB release info and feel free to tag me.
Sergio Roche
Sergio Roche 2022 年 9 月 29 日
I will do that... thanks!
Jakub
Jakub 2023 年 6 月 8 日
Hello,
I have this bug in 2018b. I tried using MException.last.stack(1) but then I get the error Index exceeds the number of array elements (0).
EFB
EFB 2023 年 10 月 15 日
Unfortunately I experience a similar problem also in R2023b. I often use pre-defined error messsages as a tool for debugging, and for these the line numbers are not shown.
I.e.
if(ii == 4 && k == 200)
error('I want to make an error here')
end
produces the error message, but I dont get to see where in the code it is.
Jeremy P
Jeremy P 2024 年 2 月 15 日
same here, I have this problem in R2023b everywhere I use the error function

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

製品

リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by