forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Error Handling
desunit edited this page Nov 29, 2012
·
23 revisions
ServiceStack and it's new API provides flexible way to intercept exceptions. If you need a single entry point for all service exceptions, you can subscribe to AppHostBase.ServiceExceptionHandler
events in Configure
method like shown below:
public override void Configure(Container container)
{
ServiceExceptionHandler += (request, exception) => {
//log your exceptions here
...
//call default exception handler or prepare your own custom response
return DtoUtils.HandleException(this, request, exception);
};
}
If you have old services you still can handle all exceptions in one single place. Create base class for your services and override HandleException
method like shown below.
public class MyServiceBase<TRequest> : RestService<TRequest>
{
public override object HandleException(TRequest request, Exception exception)
{
//log your exceptions here
...
//call default exception handler or prepare your own custom response
return base.HandleException(request, exception);
}
}
- Why ServiceStack?
- What is a message based web service?
- Advantages of message based web services
- Why remote services should use separate DTOs
- Getting Started
- Reference
- Clients
- Formats
- View Engines 4. Razor & Markdown Razor
- Hosts
- Advanced
- Configuration options
- Access HTTP specific features in services
- Logging
- Serialization/deserialization
- Request/response filters
- Filter attributes
- Concurrency Model
- Built-in caching options
- Built-in profiling
- Messaging and Redis
- Form Hijacking Prevention
- Auto-Mapping
- HTTP Utils
- Virtual File System
- Config API
- Physical Project Structure
- Modularizing Services
- Plugins
- Tests
- Other Languages
- Use Cases
- Performance
- How To
- Future