Appearance
Exception 
自定义异常,根据Http流程定义的格式,返回字符串。
与Http流程中的exceptionFormat不同,exceptionFormat输出的是程序执行时的未知异常,而Exception控件则是根据业务流程自行抛出的异常。
业务属性 
| 属性 | 说明 | 
|---|---|
| errorCode | 错误码 | 
| errorMessage | 错误信息 | 
使用示例 
以下我们以Http流程的默认值为例,介绍Exception控件的几种用法。
输出常量 
errorCode输入-1,errorMessage输入this is exception

使用curl请求接口:
$ curl http://localhost:6636/api/exception$ curl http://localhost:6636/api/exception接口返回:
json
{
  "resCode": "-1",
  "resMsg": "this is exception"
}{
  "resCode": "-1",
  "resMsg": "this is exception"
}输出指定变量 
有的时候我们需要在返回错误信息的同时,也返回异常的变量,我们可以使用StringFormat来构建异常信息。
控件的输入参数如下图:

使用curl请求接口:
$ curl http://localhost:6636/api/exception -d "{\"code\": 500, \"param\":\"errorParam\"}"$ curl http://localhost:6636/api/exception -d "{\"code\": 500, \"param\":\"errorParam\"}"接口返回:
json
{
  "resCode": "500",
  "resMsg": "error param is errorParam"
}{
  "resCode": "500",
  "resMsg": "error param is errorParam"
}