Wednesday, October 23, 2013
How to Log Errors in SharePoint Hosted Apps?
10/23/2013 01:25:00 PM |
Posted by
VijayKumar Yadavalli
|
Edit Post
It is most common thing to log error message if some exception occurs within the code, so that user can find out what causing the error. It is straight forward if you using Server side object model. Since Hosted apps only use JavaScript object model and its bit new to many of us, not sure which namespace/class to use.
We use SP.Utilities.Utility.logCustomAppError method to log the app errors. Following is the sample code
function onFail(sender, args) {
logAppError(args.get_message() + '\n' + args.get_stackTrace());
}
function logAppError(message) {
SP.Utilities.Utility.logCustomAppError(context, message);
this.context.executeQueryAsync();
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment