SharePoint exception documentation - sharepoint

I'm wondering where I can find some information about exceptions that are thrown by the SharePoint object model. Unfortunately regarding this, the documentation on MSDN is not very useful as the documentation of many methods is lacking information about what exceptions might be thrown and in which case they will be thrown.
So where do you get your information about exceptions from?

Unfortunatly the best answer is it depends. A lot of times I will start by doing a Google search of the error text.
If you are looking for a generic list of possible execptions thrown by SharePoint you will be very disappointed. There is nothing out there that I know of.
Over time you will recognize patterns that will help you.
For example one common exception I have seen is "FileNotFound". This usally occurs if I ask SharePoint to open an SPWeb or a SPList that does not exist.

Related

Log all the information about an exception

How can I write a log entry – serialising information to text – that captures all the useful information about an exception?
In Python 3, exception instances got considerably more awesome, but also more complex. They can have a __cause__ or not, can have a __context__ or not, they can have a __traceback__ or not, they have a type, and probably more wrinkles that I'm missing.
The information needed to diagnose an exception later can include any or all of this. It can also, of course, include the same information for any related (cause, or context, or …?) exception instance, recursively.
At the point of logging a caught exception (prior to re-raising it), what single “get me all the information” technique is there which I can use to record the full diagnostic information contained in the exception object, as text which will be useful to the eventual diagnosis effort?

What is a good common term for errors and warnings?

I'd like to build an OO hierarchy of errors and warnings returned to the client during a, let's say, pricing operation:
interface PricingMessage {}
interface PricingWarning extends PricingMessage {}
interface PricingError extends PricingMessage {}
class NoSuchProductError implements PricingError {
...
}
I'm not very keen on the name PricingMessage. What is the concept that includes errors and warnings?
EDIT: To be clear, I'm looking for a common concept or name for errors and warnings specifically (excluding e.g. general info messages). For instance, compilers also report errors and warnings. What are these?
Some suggestions...
"Result"
An operation has results, which could be some number of errors, warnings, notes and explicit or implied (no errors) success.
PricingResult
"Issue"
An operation ran, but with issues, some of which could be fatal (errors) and some of which might not be (warnings). If there are no issues, success is implied.
PricingIssue
"Condition"
An operation might have or be in an error condition or a warning condition. I think some compilers use "condition" as an abstract term for an error or warning.
PricingCondition
"Diagnostic"
The outcome of an operation might include diagnostics for errors and warnings. Another compiler term, I believe.
PricingDiagnostic
If you were dealing with java, or similar OO languages, the word you are looking for would be Exception. This indicates that you have reached an "exceptional" condition which needs to be handled in a controlled way.
Through looking at a few synonym lists, I found the following:
Anomaly, oddity, deviation
Alert, message, notification
Fault, misstep, failure, glitch
I prefer the name Alert. An alert IMO can have any level of severity, it could be identified as informational, warning, critical or any other level deemed appropriate.
The counter argument I have heard to this naming is the idea that alert the noun follows too closely to alert the verb, making the distinction that the object (noun) may or many not have been brought to the users attention yet (verb). In this context naming them alert could creates a bit of cognitive dissonance, and perhaps confusion for developers reasoning about your code.
The best I can propose would be to create a hard distinction be made in your code base between Alert (the object of exceptional condition) and Notification (the act of bringing the alert to the users attention) to keep things intuitive for programmers moving forward.
In theory these could be defined as events - so you could use that.
This is very subjective, but here are a few suggestions:
Output
LogEntry
In web design, the term "admonition" is sometimes used for a block of text that can be an error, warning, or informational.

Related posts functionality

I am trying to build a related posts functionality like what we see here in stackoverflow on the bottom right corner. My main difficulty is that the related posts have to be determined at runtime when loading a particular post.
I am thinking to look for posts with similar or equal set of tags, also similar titles and possibly similar sets of keywords in the main post content, the problem is that the more signals you look for the slower the database will be to return data.
I have also thought about using Google Site Search (we have an account) as Google does understand the relationship between posts very well, but unfortunately the related: parameter is broken according to Google.
I am looking for ideas on how to best achieve this. Has any of you ever done something like this? What's the best way to achieve this type of thing?

SharePoint interview questions [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Let's have a list of some good interview questions for SharePoint developers. Please provide one question per entry, and if possible, the answers.
Also, please feel free to suggest corrections if the provided answers are wrong.
I will go first:
Q: How does SharePoint store pages?
A: How-to-locate-sharepoint-document-library-source-page-on-the-server?
Q. When running with SPSecurity.RunWithElevatedPrivileges (web context) what credentials are being used?
A. The App Pool Identity for the web application running SharePoint.
Q. When modifying a list item, what is the "main" difference between using SPListItem.Update() and SPListItem.SystemUpdate()?
A. Using SystemUpdate() will not create a new version and will also retain timestamps.
Q: When should you dispose SPWeb and SPSite objects? And even more important, when not?
A: You should always dispose them if you created them yourself, but not otherwise. You should never dispose SPContext.Current.Web/Site and you should normally not dispose SPWeb if IsRootWeb is true. More tricky constructs are things along the line of SPList.ParentWeb.
Bonus Points if the candidate knows Roger Lambs Blog Post.
Q: What is the difference between System.Web.UI.WebControls.WebParts.WebPart and Microsoft.SharePoint.WebPartPages.WebPart?
A: Microsoft.SharePoint.WebPartPages.WebPart is provided in MOSS 2007 to provide backwards compatability with MOSS 2003 webparts. In MOSS 2007, it is recommended to use System.Web.UI.WebControls.WebParts.WebPart instead.
sometimes I like to ask more open ended questions to get the prospect talking.
If I want to find out technical depth
Q: What bugs have you found in SharePoint? then Q: And what did you do to work around them?
Q: What is the performance impact of RunWithElevatedPrivileges?
A: RunWithElevatedPrivileges creates a new thread with the App Pool's credentials, blocking your current thread until it finishes.
[via rexm]
Q. If you have an ItemUpdated or ItemUpdating event receiver and it causes an update to the item, how do you prevent another ItemUpdated and ItemUpdating event from being fired during your update?
A. Before performing your update, call DisableEventFiring(). After update, call EnableEventFiring().
Q. What is a site collection, why would you create a new site collection as opposed to a site?
A. Bit of a long answer, but they should know about site collection administration, quotas, seperation of assets, security model etc.
Dave Wollerman has a good article on some of the whys and wherefores.
Q: Describe the difference between a list and a library.
A: Lists are collections of metadata or columns, that can have attached documents. Libraries are collections of documents (Excel, InfoPath, Word, etc.) plus optional metadata.
Edited per ktrauberman's feedback.
Q: (i) Describe the purpose of a content type and;
(ii) give an example of where they might be used.
A: (i) A content type groups a set of list columns together so that they can be reused in the same way across sites.
(ii) They could be used as a set of metadata columns that need to be applied to every document in a site collection.
Q: Explain how SharePoint render its content.
A: Beyond scope here, but you can find some good information here: http://g-m-a-c.blogspot.com/2008/04/how-sharepoint-2007-renders-its-content.html
The applicant should at least get around the SharePoint's template rendering mechanism, and what's in the 12/TEMPLATE/CONTROLTEMPLATES/ and what it's used for with emphasis on DefaultTemplates.ascx. This is absolutely essential knowledge if you wish to do any kind of SharePoint customization.
Q: Name at least two shared services available in MOSS 2007
A: Shared Services Providers in MOSS 2007 can provide the following shared services:
User Profiles
Audiences
Personal Sites
Search
Excel Services
Forms Services
Business Data Catalog (Requires Enterprise Edition)
Q. What is the difference between MOSS & WSS
A. MOSS uses the Shared Service Provider for search, profile import, etc... (see the answers posted by Lars Fastrup for a more complete list)
Q: How would you programmatically retrieve a list item?
A: SPQuery and SPSiteDataQuery. Bonus points for knowledge of CrossListQueryCache, PortalSiteMapProvider. Negative points for use of foreach.
Good ones. here are some really useful ones.
http://megasolutions.net/qs/Sharepoint_Portal_Interview_Questions.aspx
Q: Why would you use a custom column?
A: It allows you to re-use the column in multiple libraries. Particularly useful if you use a Choice type to restrict the user input to a predefined set of answers, and when that list of answers will likely change.
Q. What base classes do event receivers inherit from?
A:
SPListEventReceiver, SPItemEventReciever, and SPWebEventReceiver inherit from the abstract base class SPEventReceiverBase.
SPWorkflowLibraryEventReceiver inherits from SPItemEventReceiver.
SPEmailEventReceiver inherits directly from System.Object.
Also see a collection of SharePoint Questions on: http://qmoss.blogspot.com/
Q: What are the built in ways to backup a SharePoint install?
A: Through the central administration and the stsadm command
Q: (more advanced) You've created and deployed a Web Part, when you deploy to the server you get a page saying your Web Part couldn't be loaded, click here to go to the Web Part maintenance page, etc. to disable the web part. What step(s) should you take to get a stack dump from your web part instead of that error page?
A: Go to the web.config file for your website and find the CallStack Attribute in the SafeControls element and set the value to true.
Describe your experiences in applying custom branding to SharePoint 2007. What are some pitfalls to avoid? How do you deploy your custom branding to the farm?
When/why should you/shouldn't you make direct changes or additions to the files in the 12 hive?
Q. How would you create a Master/Detail page?
A. Creating a Content type inheriting from Folder Content Type for the master, and another Content type inheriting from Item and using them both on a List
Describe the Business Data Catalog (BDC), and provide at least one of a tangible application for it.
Q: What is a way of elevating SharePoint privileges without using RunWithElevatedPrivileges?
A: Pass the System Account User Token from the SPContext to the SPSite constructor.
A majority of times a developer can accomplish what they need using this method without needlessly elevating network credentials.
I would rather ask some open ended questions like
Tell me something which you consider as an error that Microsoft has made in SharePoint?
Possible answers are...
For lookup columns you need to know the lookup field GUID in advance and you can’t easily provision a lookup field as a feature.
MOSS does not have site level events such as an event for creating of lists.
SharePoint designer is a crap and add unwanted stuff which increases the page size.
Lack of user group based trimming control as only permission based trimming is available by deafult (of cause you can create a custom security trimmer that does this)
Q. What are the data types which are supported as Lookup column in SharePoint.
A. Only Single Line of Text and Calculated columns are supported as lookup columns.
Also I have consolidated some more questions on: http://qmoss.blogspot.com/

Identifying Duplicate Exceptions for Bug Tracking

I've developed a "Proof of Concept" application that logs unhandled exceptions from an application to a bug-tracking system (in this case Team Foundation Server, but it could be ANY bug tracking system). A limitation of this idea is that I don't want duplicate Bug Items opened every time the same exception is thrown (for example, many users encounter the exception - it's still a single "bug").
My first attempt was to store the Exception Type, Message and Stack Trace as fields in the Bug Tracking System.The logging component would then do a query against the Bug "Store" to see if there is an open bug with the same information. (This example is .NET - but I would think the concept is platform independant).
The problem obviously is that these fields can be very large (particularly the stack trace) - and requires a "Full-Text" type of implementation to store them and the searching is very expensive.
I was wondering what approaches have been defined for this problem. I had heard that FogBugz for example had such a feature for automated bug tracking, and was curious how it was implemented.
If you have the stack trace, you could find the last statement in the stack trace and compare it with the ones already logged. If the symbols were included, you'd also get the line number. So, now you have two things for comparison, the actual error number and the statement that failed and possibly the actual line number. If something has already been logged with all of those, then it's more than likely (not 100%, of course) the same issue.
In fact, you could probably parse the stack trace with the "at" word, as each line in the stack trace begins with "at". So, look for the last "at", get that line, compare it with the same last "at" line of the stored stack traces, and you might actually have something.
HTH!
You could create a checksum hash of the stack trace and store that as an indexed column. That way the query to the Bug Store would be pretty fast to avoid duplicates on insert.
You could look at the source code for one of the existing open-source solutions that aggregate exceptions.
For example: https://github.com/getsentry/sentry/tree/master/src/sentry
It is not a simple problem and there are complex heuristics (e.g. same exception reported different ways on different browsers, e.g. exceptions caused by browser extensions are common and are rarely important).

Resources