# blade create servlet throwCustomException

## 介绍

Java web 请求异常

## 参数

以下是此场景特有参数，通用参数详见：\[blade create servlet]\(blade create servlet.md)

```
--exception string           异常类，带全包名，必须继承 java.lang.Exception 或 java.lang.Exception 本身
--exception-message string   指定异常类信息，默认值是 chaosblade-mock-exception
```

## 案例

访问 <http://localhost:8080/dubbodemo/hello?code=1> 请求异常，影响 3 条请求

```
blade c servlet throwCustomException --exception org.springframework.beans.BeansException --exception-message mock-beans-exception --requestpath /hello --effect-count 3

{"code":200,"success":true,"result":"d4a63f4f59f76f4a"}
```

访问请求进行验证。

![](/files/1PNGWM4zytLpEYAvZW0l)

查看日志，通过日志也可以看出 ![](/files/ALmFCLkjZBtKmR0vUIi8)

## 实验原理

## 常见问题


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chaosblade-io.gitbook.io/chaosblade-help-zh-cn/blade-create-servlet/blade-create-servlet-throwcustomexception.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
