Skip to main content

Answered Question How do you properly pass an exception from server to client?RSS Feed

(0)

enantiomer2000
enantiom...

Member

Member

45 points

62 Posts

How do you properly pass an exception from server to client?

I have a class that extends the AuthorizationAttribute class so that I can do my own authorization for my application.  Everything is all set up very nicely BUT if the user isn't authorized to call the DomainService method, I want to have my client receive my own exception.  Currently the only exception I ever see is EntityOperationException.  EntityOperationException just has the Message string from my original exception, but doesn't have any InnerException (it is null). 

How can I pass exceptions from server to client?  I would rather not try to parse the Message property string to interpret my error.  Any ideas?  I can't find anything about this in the documentation.

Thanks.

Sledge70
Sledge70

Contributor

Contributor

7426 points

1,285 Posts

Re: How do you properly pass an exception from server to client?

Have you enabled includeExceptionDetailsInFaults for wcf?

<serviceDebug includeExceptionDetailInFaults="true"/>

This will at least get the inner exception populated.

______________________________________________________
Please mark replies as answers if they answered your question...

Flexman on Silverlight

enantiomer2000
enantiom...

Member

Member

45 points

62 Posts

Re: How do you properly pass an exception from server to client?

 Does that work for a DomainService?  I am not calling a WCF service directly here.  Where would you set the DomainService to use the behavior?  Is this the type of setting you would want to use for a production environment?

ColinBlair
ColinBlair

Star

Star

11673 points

2,103 Posts

Re: How do you properly pass an exception from server to client?

enantiomer2000:

 Does that work for a DomainService?  I am not calling a WCF service directly here.  Where would you set the DomainService to use the behavior?  Is this the type of setting you would want to use for a production environment?

Not at the moment, as soon as the ADO.NET Services hosted version of RIA Services shows up then that will change.

-Colin Blair

http://www.RiaServicesBlog.net : The Elephant Guide to RIA Services
SLColinBlair on Twitter

enantiomer2000
enantiom...

Member

Member

45 points

62 Posts

Re: How do you properly pass an exception from server to client?

 @ColinBlair

 Thanks for the info.  So for now the best thing to do is probably to pass a DomainServiceException with an error code?  

"as soon as the ADO.NET Services hosted version of RIA Services shows up.."

Can you explain this more?  Do you mean when it goes live and is integrated into ADO.Net Services?  The entity framework guys have a blog where you can keep up to date with the latest developments, do the RIA Services guys have one too?

Thanks.

ColinBlair
ColinBlair

Star

Star

11673 points

2,103 Posts

Answered Question

Re: How do you properly pass an exception from server to client?

enantiomer2000:
Thanks for the info.  So for now the best thing to do is probably to pass a DomainServiceException with an error code?

Yes

enantiomer2000:
Can you explain this more?  Do you mean when it goes live and is integrated into ADO.Net Services?  The entity framework guys have a blog where you can keep up to date with the latest developments, do the RIA Services guys have one too?

RIA Services will be integrated with ADO.NET Data Services by the PDC timeframe. When that happens WCF configuration will start working since ADO.NET Data Services is WCF based. Currently RIA Services is running on a plain HTTPHandler and there really isn't much plumbing in there.

There is no RIA Services blog (well, other than mine), just lots of individual blogs and twitters. I just got started on twitter and I try to re-tweet anything RIA Services related that comes by.

-Colin Blair

http://www.RiaServicesBlog.net : The Elephant Guide to RIA Services
SLColinBlair on Twitter

enantiomer2000
enantiom...

Member

Member

45 points

62 Posts

Re: How do you properly pass an exception from server to client?

 Thanks for the info.  Guess I will have to check this Twitter thing out too.

  • Unanswered Question
  • Answered Question
  • Announcement