Error handling
Contents
[
Hide
]
The source code for complex, deeply nested forms may be very complex and difficult to read. Aspose.OMR offers an easy-to-use method for detecting errors when generating printable forms.
To validate the source code, examine ErrorCode
property of the GenerationResult
object returned by GenerateTemplate
or GenerateJSONTemplate
methods. If the property’s value is 0
, the source code is valid and the generated form can be saved. Otherwise, there is an error in the source code and you can get a human-readable error in ErrorMessage
property.
Alternatively, you can catch an exception from Save
or SaveAsPdf
methods of of the GenerationResult
object returned by GenerateTemplate
or GenerateJSONTemplate
methods.
Example
Aspose.OMR.Api.OmrEngine omrEngine = new Aspose.OMR.Api.OmrEngine();
Aspose.OMR.Generation.GenerationResult generationResult = omrEngine.GenerateTemplate("source.txt");
if(generationResult.ErrorCode != 0)
{
Console.WriteLine(generationResult.ErrorMessage);
return generationResult.ErrorCode;
}
generationResult.Save("", "OMR-Form");