https://docs.microsoft.com/en-us/dotnet/framework/wcf/wcf-error-handling

The errors encountered by a WCF application belong to one of three groups:

  1. Communication Errors

  2. Proxy/Channel Errors

  3. Application Errors

Communication errors occur when a network is unavailable, a client uses an incorrect address, or the service host is not listening for incoming messages. Errors of this type are returned to the client as CommunicationException or CommunicationException-derived classes.

Proxy/Channel errors are errors that occur within the channel or proxy itself. Errors of this type include: attempting to use a proxy or channel that has been closed, a contract mismatch exists between the client and service, or the client’s credentials are rejected by the service. There are many different types of errors in this category, too many to list here. Errors of this type are returned to the client as-is (no transformation is performed on the exception objects).

Application errors occur during the execution of a service operation. Errors of this kind are sent to the client as FaultException or FaultException<TDetail>.

Error handling in WCF is performed by one or more of the following:

  • Directly handling the exception thrown. This is only done for communication and proxy/channel errors.

  • Using fault contracts

  • Implementing the IErrorHandler interface

  • Handling ServiceHost events

Fault Contracts

Fault contracts allow you to define the errors that can occur during service operation in a platform independent way. By default all exceptions thrown from within a service operation will be returned to the client as a FaultException object. The FaultException object will contain very little information. You can control the information sent to the client by defining a fault contract and returning the error as a FaultException<TDetail>. For more information, see Specifying and Handling Faults in Contracts and Services.

IErrorHandler

The IErrorHandler interface allows you more control over how your WCF application responds to errors. It gives you full control over the fault message that is returned to the client and allows you to perform custom error processing such as logging. For more information about IErrorHandler and Extending Control Over Error Handling and Reporting

ServiceHost Events

The ServiceHost class hosts services and defines several events that may be needed for handling errors. For example:

  1. Faulted

  2. UnknownMessageReceived

For more information, see ServiceHost

WCF Error Handling的更多相关文章

  1. Erlang error handling

    Erlang error handling Contents Preface try-catch Process link Erlang-way error handling OTP supervis ...

  2. MySQL Error Handling in Stored Procedures 2

    Summary: this tutorial shows you how to use MySQL handler to handle exceptions or errors encountered ...

  3. setjmp()、longjmp() Linux Exception Handling/Error Handling、no-local goto

    目录 . 应用场景 . Use Case Code Analysis . 和setjmp.longjmp有关的glibc and eglibc 2.5, 2.7, 2.13 - Buffer Over ...

  4. Error Handling

    Use Exceptions Rather Than Return Codes Back in the distant past there were many languages that didn ...

  5. Error Handling and Exception

    The default error handling in PHP is very simple.An error message with filename, line number and a m ...

  6. Clean Code–Chapter 7 Error Handling

    Error handling is important, but if it obscures logic, it's wrong. Use Exceptions Rather Than Return ...

  7. [RxJS] Error handling operator: catch

    Most of the common RxJS operators are about transformation, combination or filtering, but this lesso ...

  8. MySQL Error Handling in Stored Procedures---转载

    This tutorial shows you how to use MySQL handler to handle exceptions or errors encountered in store ...

  9. Error Handling in ASP.NET Core

    Error Handling in ASP.NET Core 前言  在程序中,经常需要处理比如 404,500 ,502等错误,如果直接返回错误的调用堆栈的具体信息,显然大部分的用户看到是一脸懵逼的 ...

随机推荐

  1. ugui代码设置ui锚点

    using UnityEngine; public enum AnchorPresets { TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCente ...

  2. 第四周实验报告&实验总结

    试验报告2 写一个名为Rectangle的类表示矩形.其属性包括宽width.高height和颜色color,width和height都是double型的,而color则是String类型的.要求该类 ...

  3. RandomAccessFile类使用说明

    RandomAccessFile类是Java Io体系中功能最为丰富的文件访问类,它提供了众多的文件访问方法.RandomAccessFile类支持“随机访问”方式,这里的“随机”是指程序可以直接跳到 ...

  4. Kotlin学习(2)函数

    函数声明: fun plus(a:Int,b:String):Boolean{ //fun 函数名(参数名:参数类型,参数名:参数类型):返回值类型 println(a) return true // ...

  5. 使用 js 修饰器封装 axios

    修饰器 修饰器是一个 JavaScript 函数(建议是纯函数),它用于修改类属性/方法或类本身.修饰器提案正处于第二阶段,我们可以使用 babel-plugin-transform-decorato ...

  6. GooglePlay

    如何下载googlePLay的apk文件? 1.首先要知道apk的package名: 打开GooglePlay的页面,在地址栏里就会有https://play.google.com/store/app ...

  7. jquery获取年月日时分秒当前时间

    获取年月日时分秒的当前时间,可按照某种格式显示出来,下面是一种得到如2017年02月02日  00:00:00格式的当前时间 function getCurrentDate(date){ var y ...

  8. 安装paramiko的方法

    打开cmd命令行 输入 cd /d C:\Python27\Scripts 输入 pip  install paramiko pip install pika -i https://pypi.doub ...

  9. iOS 应用配置及证书生成教程

    简介 首先你需要有一个苹果的开发者帐号,一台苹果电脑.点击查看苹果开发者账号注册流程 本教程需完成应用信息配置,包括如下两个基本配置: AppID Bundle ID 同时,生成 如下三个证书文件及对 ...

  10. 洛谷P3158 [CQOI2011]放棋子 组合数学+DP

    题意:在一个m行n列的棋盘里放一些彩色的棋子,使得每个格子最多放一个棋子,且不同颜色的棋子不能在同一行或者同一列.有多少祌方法? 解法:这道题不会做,太菜了qwq.题解是看洛谷大佬的. 设C是组合数, ...