Показать сообщение отдельно
Старый 12.12.2021, 11:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,646 / 848 (80) +++++++
Регистрация: 28.10.2006
dynamicsaxinsight: AX 2012: Handling CLR exceptions
Источник: https://dynamicsaxinsight.wordpress....lr-exceptions/
==============

Purpose:

The purpose of this post is to demonstrate how can we effectively handle CLR exceptions.

Application:

Dynamics AX 2012

Business requirement:

To report CLR inner exception.

Solution:

Please find the code below to get the inner CLR exception.

Code

private void getFiles(){ System.String[] files; System.Collections.IEnumerator enumerator; str file; ; try { fileSet = new Set(Types::Container); files = System.IO.Directory::GetFiles(filePath, '*.csv'); enumerator = files.GetEnumerator(); while (enumerator.MoveNext()) { file = enumerator.get_Current(); fileSet.add([file]); } } catch (Exception::Internal) { this.processCLRErrorException(); } catch (Exception::CLRError) { this.processCLRErrorException(); }}
private void processCLRErrorException(boolean _throw = true){ CLRObject exc; CLRObject innerExc; CLRObject clrExcMessage; str strError; ; exc = CLRInterop::getLastException(); if (exc) { innerExc = exc.get_InnerException(); clrExcMessage = exc.get_Message(); while (innerExc != null) { innerExc = innerExc.get_InnerException(); clrExcMessage = innerExc.get_Message(); } strError = CLRInterop::getAnyTypeForObject(clrExcMessage); error(strError); if (_throw) { throw error("Update has been cancelled"); } }}



Источник: https://dynamicsaxinsight.wordpress....lr-exceptions/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.