Handling Exceptions using Aspose.Tasks

Handling Exceptions While Working with Microsoft Project Files

Sometimes, Aspose customers are unable to load their projects because of unsupported features and other issues and do not want to share their projects for analysis on our Support forums.

The LogText property exposed by the TasksReadingException class is used to deal with such cases. You can use this property to identify the problematic section of the project, for example, a problematic task, resource, resource assignment etc.

After identifying the section that’s causing the problem, you can try to resolve the issue at your end or copy that data to a separate project and share with us to resolve the issue.

The following code is used to identify the cause of the exception.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(HandleExceptions.class);
 4
 5Project project;
 6try {
 7    project = new Project(dataDir + "ProjectWithException.mpp");
 8} catch (TasksReadingException ex) {
 9    System.out.println("Message:");
10    System.out.println(ex.getMessage());
11    System.out.println("Log:");
12    System.out.println(ex.getLogText());
13
14    if (ex.getCause() != null) {
15        System.out.println("Inner exception message:");
16        System.out.println(ex.getCause().getMessage());
17    }
18
19} catch (Exception e) {
20    System.out.println(e.getMessage());
21}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.