已合并
提交自定义错误玛 #33989
pangyucheng创建于 7月2日
提交自定义错误玛 #33989
已合并
共 4 个文件变更+83-0
| @@ -3353,6 +3353,14 @@ declare class WebResourceError { | |||
| 3353 | * 8 dynamic | 3353 | * 8 dynamic |
| 3354 | */ | 3354 | */ |
| 3355 | getErrorCode(): number; | 3355 | getErrorCode(): number; |
| 3356 | + /** | ||
| 3357 | + * Gets the custom error code of the Web resource. | ||
| 3358 | + * | ||
| 3359 | + * { number } Return the custom error code of the Web resource. | ||
| 3360 | + * SystemCapability.Web.Webview.Core | ||
| 3361 | + * 26.1.0 dynamic | ||
| 3362 | + */ | ||
| 3363 | + getCustomErrorCode(): number; | ||
| 3356 | } | 3364 | } |
| 3357 | 3365 | ||
| 3358 | /** | 3366 | /** |
| @@ -6752,6 +6752,25 @@ declare namespace webview { | |||
| 6752 | * 12 dynamic | 6752 | * 12 dynamic |
| 6753 | */ | 6753 | */ |
| 6754 | getHeaderByName(name: string): string; | 6754 | getHeaderByName(name: string): string; |
| 6755 | + /** | ||
| 6756 | + * Set the custom error code for the Web response. | ||
| 6757 | + * | ||
| 6758 | + * { number } customErrorCode - The custom error code for this response, Web engine will pass the custom | ||
| 6759 | + * error code directly to the application through onErrorReceive. | ||
| 6760 | + * SystemCapability.Web.Webview.Core | ||
| 6761 | + * | ||
| 6762 | + * 26.1.0 dynamic | ||
| 6763 | + */ | ||
| 6764 | + setCustomErrorCode(customErrorCode: number): void; | ||
| 6765 | + /** | ||
| 6766 | + * Get the custom error code of the Web response. | ||
| 6767 | + * | ||
| 6768 | + * { number } Return the custom error code that was set for this response. | ||
| 6769 | + * SystemCapability.Web.Webview.Core | ||
| 6770 | + * | ||
| 6771 | + * 26.1.0 dynamic | ||
| 6772 | + */ | ||
| 6773 | + getCustomErrorCode(): number; | ||
| 6755 | } | 6774 | } |
| 6756 | 6775 | ||
| 6757 | /** | 6776 | /** |
| @@ -6825,6 +6844,20 @@ declare namespace webview { | |||
| 6825 | * 20 dynamic | 6844 | * 20 dynamic |
| 6826 | */ | 6845 | */ |
| 6827 | didFail(code: WebNetErrorList, completeIfNoResponse: boolean): void; | 6846 | didFail(code: WebNetErrorList, completeIfNoResponse: boolean): void; |
| 6847 | + /** | ||
| 6848 | + * Notify that this request should be failed. | ||
| 6849 | + * | ||
| 6850 | + * { WebNetErrorList } code - Set response error code to intercept. | ||
| 6851 | + * { boolean } completeIfNoResponse - If completeIfNoResponse is true, when DidFailWithError is called, | ||
| 6852 | + * if DidReceiveResponse has not been called, a response is automatically constructed and the current | ||
| 6853 | + * request is terminated. | ||
| 6854 | + * { number } customErrorCode - The custom error code for this response, Web engine will pass the custom | ||
| 6855 | + * error code directly to the application through onErrorReceive. | ||
| 6856 | + * { BusinessError } 17100021 - The resource handler is invalid. | ||
| 6857 | + * SystemCapability.Web.Webview.Core | ||
| 6858 | + * 26.1.0 dynamic | ||
| 6859 | + */ | ||
| 6860 | + didFail(code: WebNetErrorList, completeIfNoResponse: boolean, customErrorCode: number): void; | ||
| 6828 | } | 6861 | } |
| 6829 | 6862 | ||
| 6830 | /** | 6863 | /** |
| @@ -5676,6 +5676,26 @@ declare namespace webview { | |||
| 5676 | * @since 23 static | 5676 | * @since 23 static |
| 5677 | */ | 5677 | */ |
| 5678 | getHeaderByName(name: string): string | 5678 | getHeaderByName(name: string): string |
| 5679 | + /** | ||
| 5680 | + * Set the custom error code for the Web response. | ||
| 5681 | + * | ||
| 5682 | + * @param { int } customErrorCode - The custom error code for this response, Web engine will pass the custom | ||
| 5683 | + * error code directly to the application through onErrorReceive. | ||
| 5684 | + * <br>The value should be an integer. | ||
| 5685 | + * @syscap SystemCapability.Web.Webview.Core | ||
| 5686 | + * @stagemodelonly | ||
| 5687 | + * @since 26.1.0 static | ||
| 5688 | + */ | ||
| 5689 | + setCustomErrorCode(customErrorCode: int): void; | ||
| 5690 | + /** | ||
| 5691 | + * Get the custom error code of the Web response. | ||
| 5692 | + * | ||
| 5693 | + * @returns { int } Return the custom error code that was set for this response. | ||
| 5694 | + * @syscap SystemCapability.Web.Webview.Core | ||
| 5695 | + * @stagemodelonly | ||
| 5696 | + * @since 26.1.0 static | ||
| 5697 | + */ | ||
| 5698 | + getCustomErrorCode(): int; | ||
| 5679 | } | 5699 | } |
| 5680 | 5700 | ||
| 5681 | /** | 5701 | /** |
| @@ -5738,6 +5758,20 @@ declare namespace webview { | |||
| 5738 | * @since 23 static | 5758 | * @since 23 static |
| 5739 | */ | 5759 | */ |
| 5740 | didFail(code: WebNetErrorList, completeIfNoResponse: boolean): void; | 5760 | didFail(code: WebNetErrorList, completeIfNoResponse: boolean): void; |
| 5761 | + /** | ||
| 5762 | + * Notify that this request should be failed. | ||
| 5763 | + * | ||
| 5764 | + * @param { WebNetErrorList } code - Set response error code to intercept. | ||
| 5765 | + * @param { boolean } completeIfNoResponse - If completeIfNoResponse is true, when DidFailWithError is called, | ||
| 5766 | + * if DidReceiveResponse has not been called, a response is automatically constructed and the current | ||
| 5767 | + * request is terminated. | ||
| 5768 | + * @param { int } customErrorCode - The custom error code for this response, Web engine will pass the custom | ||
| 5769 | + * error code directly to the application through onErrorReceive. | ||
| 5770 | + * @throws { BusinessError } 17100021 - The resource handler is invalid. | ||
| 5771 | + * @syscap SystemCapability.Web.Webview.Core | ||
| 5772 | + * @since 26.1.0 static | ||
| 5773 | + */ | ||
| 5774 | + didFail(code: WebNetErrorList, completeIfNoResponse: boolean, customErrorCode: int): void; | ||
| 5741 | } | 5775 | } |
| 5742 | 5776 | ||
| 5743 | /** | 5777 | /** |
| @@ -2611,6 +2611,14 @@ export declare class WebResourceError { | |||
| 2611 | * @since 23 static | 2611 | * @since 23 static |
| 2612 | */ | 2612 | */ |
| 2613 | getErrorCode(): int; | 2613 | getErrorCode(): int; |
| 2614 | + /** | ||
| 2615 | + * Gets the custom error code of the Web resource. | ||
| 2616 | + * | ||
| 2617 | + * @returns { int } Return the custom error code of the Web resource. | ||
| 2618 | + * @syscap SystemCapability.Web.Webview.Core | ||
| 2619 | + * @since 26.1.0 static | ||
| 2620 | + */ | ||
| 2621 | + getCustomErrorCode(): int; | ||
| 2614 | } | 2622 | } |
| 2615 | /** | 2623 | /** |
| 2616 | * Defines the js geolocation request. | 2624 | * Defines the js geolocation request. |