Do Try Catch In Old NAV

攻城人生 RED Lin 2022-10-28 89

呼叫、使用的dll function 會 throw out error
希望能捕捉這個error客制訊息或是由開發者決定要不要 throw out

古老的 NAV codeunit 還沒有 Try Function 可以用的版本裡
可以用

1
2
3
4
5
6
if codeunit.run then
// things when success
else begin
error(getlasterrortext());
clearlasterror();
end;

ref: https://community.dynamics.com/nav/f/microsoft-dynamics-nav-forum/115550/change-in-code-unit-error-handling-with-2013-r2/236823