Tuesday, February 12, 2013

How to return custom error messages in ECMA2 SP1

While updating my Management Agents (or connectors) and building a new one for a customer, I wanted to take advantage of the new possibility in the Service Pack 1 version of the ECMA2 framework where you can return a custom errorname and error detail to the Synchronization Service Manager. It took me sometime to get my head around this, but I finally got it working.

Before Service Pack 1, you could also use the CSEntryChangeResult to return a error on your imports and export actions. In your PutExportEntries interface code, you would put something like this to return a export error -

CSEntryChangeResult cschangeresult = CSEntryChangeResult.Create(csentryChange.Identifier, null, MAExportError.ExportErrorSyntaxViolation);

This line above would show up as a export error with the error code 'syntax-violation' in the Synchronization Service Manager. You can find the additional MAExportError options here (http://msdn.microsoft.com/en-us/library/microsoft.metadirectoryservices.maexporterror(v=vs.100).aspx).

With Service Pack 1, however, you are now able to return a custom error name and detail, which is awesome because you can give more information to the administrator. The caveat is that you do need to set MAExportError to either ExportErrorCustomContinueRun or ExportErrorCustomStopRun for your custom error information to be returned. These two enumeration options are new for Service Pack 1 and I was struggling for a few hours before I noticed these.

So after changing my MAExportError enumeration value to ExportErrorCustomContinueRun, my custom error message was returned to the Synchronization Service Manager. My line now looks like this -

CSEntryChangeResult cschangeresult = CSEntryChangeResult.Create(csentryChange.Identifier, null, MAExportError.ExportErrorCustomContinueRun, "script-error", scriptResult);

Notice that I keep my error name to the general, well-known syntax of <warning/error>-<message> (second last parameter). I just like this as a best practise but it is not a requirement; you can write any text, you like.

Happy coding.


Jason Bell said...

Perfect! I have been trying to figure this out out also. Sometimes the most difficult problem to solve is the one that is easiest to see.

Kayal said...

I like this blog, this is a very simple but very good explanation about this useful topic. Well done and keep continuing...
Oracle Training in Chennai
Oracle Training institute in chennai
Social Media Marketing Courses in Chennai
Tableau Training in Chennai
Primavera Training in Chennai
Unix Training in Chennai
Oracle DBA Training in Chennai
Power BI Training in Chennai
Oracle Training in Chennai
Oracle Training institute in chennai

Reshma said...

Nice blog! Thanks for sharing this valuable information
Software Testing Training in Chennai
Software Testing Training in Bangalore
Software Testing Course in Coimbatore
Software Testing Training in Madurai
Software Testing Training Institute in Bangalore
Software Testing Course in Bangalore
Testing Course in Bangalore
Ethical hacking course in bangalore

sasi said...

The blog you shared is very good. I expect more information from you like this blog. Thankyou.
Web Designing Course in chennai
Web Designing Course in bangalore
web designing course in coimbatore
web designing training in bangalore
web designing course in madurai
Web Development courses in bangalore
web design training in coimbatore
Salesforce training in bangalore

thagukavi said...

Amazing Post. keep update more information.
IELTS Coaching in Chennai
IELTS Coaching centre in Chennai
IELTS Online Coaching
IELTS Coaching in Coimbatore
IELTS coaching in Madurai

roy rinjo said...

valuable blog, Informative content...thanks for sharing, Waiting for the next update...
Cyber Security Course in Chennai
Cyber Security Training in Chennai

parithiela said...

Nice blog, very informative content.Thanks for sharing, waiting for the next update…
aws for beginners
aws study material

Saraiyu S said...

Really informative Blog...Thanks for sharing...Waiting for next update…

Photoshop Classes in Chennai
Photoshop Course in Chennai

hema said...

Thank you for the useful blog. It's very interesting. Share more updates.
English Grammar
First conditional