• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback } from './basic';
17import * as _ErrorObserver from './application/ErrorObserver';
18
19/**
20 * This module provides the function of error manager.
21 * @namespace errorManager
22 * @syscap SystemCapability.Ability.AbilityRuntime.Core
23 * @since 9
24 */
25declare namespace errorManager {
26    /**
27     * Register error observer.
28     * @param { string } type - error.
29     * @param { ErrorObserver } observer - The error observer.
30     * @returns { number } Returns the number code of the observer.
31     * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
32     * @throws { BusinessError } 16000003 - Id does not exist.
33     * @syscap SystemCapability.Ability.AbilityRuntime.Core
34     * @since 9
35     */
36    function on(type: "error", observer: ErrorObserver): number;
37
38    /**
39     * Unregister error observer.
40     * @param { string } type - error.
41     * @param { number } observerId - Indicates the number code of the observer.
42     * @param { AsyncCallback<void> } callback - The callback of off.
43     * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
44     * @throws { BusinessError } 16000003 - Id does not exist.
45     * @syscap SystemCapability.Ability.AbilityRuntime.Core
46     * @since 9
47     */
48    function off(type: "error", observerId: number, callback: AsyncCallback<void>): void;
49
50    /**
51     * Unregister error observer.
52     * @param { string } type - error.
53     * @param { number } observerId - Indicates the number code of the observer.
54     * @returns { Promise<void> } The promise returned by the function.
55     * @throws { BusinessError } 401 - If the input parameter is not valid parameter.
56     * @throws { BusinessError } 16000003 - Id does not exist.
57     * @syscap SystemCapability.Ability.AbilityRuntime.Core
58     * @since 9
59     */
60    function off(type: "error", observerId: number): Promise<void>;
61
62    /**
63     * The observer will be called by system when an error occurs.
64     * @syscap SystemCapability.Ability.AbilityRuntime.Core
65     * @since 9
66     */
67    export type ErrorObserver = _ErrorObserver.default
68}
69
70export default errorManager;
71