Troubleshooting the OnBase Unity API

Troubleshooting the OnBase Unity API

As with all application development, it is important to plan for errors when working with the OnBase Unity API. Whenever a call to the OnBase API results in an error, a Unity API Exception will be thrown. With OnBase Version 8.2, Hyland introduced a new Diagnostics Console. This new console now has a separate tab for unity messaging. As applications become more and more complex, there needs to be more and more logging to help troubleshoot; this is where the new Unity Diagnostics come into play. This new console gives the developer a specific place to write debugging information.

Why Log?

Logging is an essential aspect of any application, it allows developers, support personnel, and end users know things have not gone correct and what the specific error is

What to Log:

All applications should log as much information as needed to determine if there is an error and what and where that error is. It is always good practice to use the WriteIf method (described below).

When to Log:

Logging should occur whenever a major event has taken place (i.e., an exception is thrown).

Where to Run:

The Diagnostics console should be run from the same machine that is running the custom Unity Application.

In Unity, writing to the Diagnostics Console is very simple. There are two methods that can be used to write to the Unity API tab in the Diagnostics Console: Write and WriteIf.

 

Write Method

One way to write to the Diagnostics Console is to create an application object, and then use the Write method of the Diagnostics property. The Write method takes in either the exception or a string parameter. The following is an example:

WriteIf Method

Another way to write to the Diagnostics Console is to create an application object, and then use the WriteIf method off the Diagnostics property. The WriteIf method takes an additional parameter called DiagnosticsLevel to determine if the application should write to the Diagnostics Console. There are five separate levels that can be defined.

 

By checking the DiagnosticsLevel, the API can be set to different modes of logging. The different levels are inclusive, meaning the higher levels include the lower levels. The levels of hierarchy are:

  • Verbose
  • Info
  • Warning
  • Error

For example, Verbose will include all the lower levels: Info, Warning, and Error. The Warning Level will include Errors, but not Info.

To use the WriteIf method, the application has to pass on the level parameter:

When the application writes to the Diagnostics Console, all messages will appear in the Unity Messages tab.

 

Blog by Alvaro Martinez

No Comments

Post A Comment