提交 ef50001a 编写于 作者: Z zhengjiangliang

错误码整改文档格式修改

Change-Id: I33f1c5fe32603eefb1d51dba1a56f0f0e54315e7
Signed-off-by: Nzhengjiangliang <zhengjiangliang@huawei.com>
上级 cffd13e8
...@@ -89,8 +89,9 @@ getDefaultDisplaySync(): Display ...@@ -89,8 +89,9 @@ getDefaultDisplaySync(): Display
**示例:** **示例:**
```js ```js
let displayClass = null;
try { try {
let displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}; };
...@@ -208,8 +209,9 @@ try { ...@@ -208,8 +209,9 @@ try {
return; return;
}; };
let ret = undefined;
try { try {
let ret = display.hasPrivateWindow(displayClass.id); ret = display.hasPrivateWindow(displayClass.id);
} catch (exception) { } catch (exception) {
console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception)); console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
}; };
...@@ -243,7 +245,7 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void ...@@ -243,7 +245,7 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void
```js ```js
let callback = (data) => { let callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data)); console.info('Listening enabled. Data: ' + JSON.stringify(data));
} };
try { try {
display.on("add", callback); display.on("add", callback);
} catch (exception) { } catch (exception) {
...@@ -445,8 +447,9 @@ getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void ...@@ -445,8 +447,9 @@ getCutoutInfo(callback: AsyncCallback&lt;CutoutInfo&gt;): void
**示例:** **示例:**
```js ```js
let displayClass = null;
try { try {
let displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}; };
...@@ -483,8 +486,9 @@ getCutoutInfo(): Promise&lt;CutoutInfo&gt; ...@@ -483,8 +486,9 @@ getCutoutInfo(): Promise&lt;CutoutInfo&gt;
**示例:** **示例:**
```js ```js
let displayClass = null;
try { try {
let displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}; };
......
...@@ -39,7 +39,7 @@ getAllScreens(callback: AsyncCallback&lt;Array&lt;Screen&gt;&gt;): void ...@@ -39,7 +39,7 @@ getAllScreens(callback: AsyncCallback&lt;Array&lt;Screen&gt;&gt;): void
**示例:** **示例:**
```js ```js
var screenClass = null; let screenClass = null;
screen.getAllScreens((err, data) => { screen.getAllScreens((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to get all screens . Cause: ' + JSON.stringify(err)); console.error('Failed to get all screens . Cause: ' + JSON.stringify(err));
...@@ -75,7 +75,7 @@ getAllScreens(): Promise&lt;Array&lt;Screen&gt;&gt; ...@@ -75,7 +75,7 @@ getAllScreens(): Promise&lt;Array&lt;Screen&gt;&gt;
**示例:** **示例:**
```js ```js
var screenClass = null; let screenClass = null;
let promise = screen.getAllScreens(); let promise = screen.getAllScreens();
promise.then((data) => { promise.then((data) => {
screenClass = data[0]; screenClass = data[0];
......
...@@ -592,6 +592,7 @@ minimizeAll(id: number): Promise&lt;void&gt; ...@@ -592,6 +592,7 @@ minimizeAll(id: number): Promise&lt;void&gt;
import display from '@ohos.display' import display from '@ohos.display'
import window from '@ohos.window' import window from '@ohos.window'
let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) { } catch (exception) {
...@@ -923,7 +924,7 @@ create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&l ...@@ -923,7 +924,7 @@ create(ctx: BaseContext, id: string, type: WindowType, callback: AsyncCallback&l
```js ```js
let windowClass = null; let windowClass = null;
window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { window.create(this.context, 'alertWindow', window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(err)); console.error('Failed to create the window. Cause: ' + JSON.stringify(err));
return; return;
...@@ -998,7 +999,7 @@ find(id: string, callback: AsyncCallback&lt;Window&gt;): void ...@@ -998,7 +999,7 @@ find(id: string, callback: AsyncCallback&lt;Window&gt;): void
```js ```js
let windowClass = null; let windowClass = null;
window.find('alertWindow', (err, data) => { window.find('alertWindow', (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); console.error('Failed to find the Window. Cause: ' + JSON.stringify(err));
return; return;
...@@ -2354,25 +2355,20 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void ...@@ -2354,25 +2355,20 @@ loadContent(path: string, storage: LocalStorage, callback: AsyncCallback&lt;void
**示例:** **示例:**
```ts ```ts
class myAbility extends Ability { let storage = new LocalStorage();
storage : LocalStorage storage.setOrCreate('storageSimpleProp',121);
onWindowStageCreate(windowStage) { console.log('onWindowStageCreate');
this.storage = new LocalStorage(); try {
this.storage.setOrCreate('storageSimpleProp',121); windowClass.loadContent('pages/page2', storage, (err) => {
console.log('onWindowStageCreate');
try {
windowStage.loadContent('pages/page2',this.storage,(err) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
}
}
``` ```
### loadContent<sup>9+</sup> ### loadContent<sup>9+</sup>
...@@ -2410,26 +2406,19 @@ loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt; ...@@ -2410,26 +2406,19 @@ loadContent(path: string, storage: LocalStorage): Promise&lt;void&gt;
**示例:** **示例:**
```ts ```ts
class myAbility extends Ability { let storage = new LocalStorage();
storage : LocalStorage storage.setOrCreate('storageSimpleProp',121);
onWindowStageCreate(windowStage) { console.log('onWindowStageCreate');
this.storage = new LocalStorage(); try {
this.storage.setOrCreate('storageSimpleProp',121); let promise = windowClass.loadContent('pages/page2', storage);
console.log('onWindowStageCreate'); promise.then(() => {
let windowClass = null;
try {
let promise = windowStage.loadContent('pages/page2',this.storage);
promise.then(()=> {
windowClass = data;
console.info('Succeeded in loading the content.'); console.info('Succeeded in loading the content.');
}).catch((err)=>{ }).catch((err) => {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
}); });
} catch (exception) { } catch (exception) {
console.error('Failed to load the content. Cause:' + JSON.stringify(exception)); console.error('Failed to load the content. Cause:' + JSON.stringify(exception));
}; };
}
}
``` ```
### isWindowShowing<sup>9+</sup> ### isWindowShowing<sup>9+</sup>
...@@ -2725,7 +2714,7 @@ off(type: 'screenshot', callback?: Callback&lt;void&gt;): void ...@@ -2725,7 +2714,7 @@ off(type: 'screenshot', callback?: Callback&lt;void&gt;): void
```js ```js
let callback = ()=>{ let callback = ()=>{
console.info('screenshot happened'); console.info('screenshot happened');
} };
try { try {
windowClass.on('screenshot', callback); windowClass.on('screenshot', callback);
} catch (exception) { } catch (exception) {
...@@ -3751,13 +3740,13 @@ snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void ...@@ -3751,13 +3740,13 @@ snapshot(callback: AsyncCallback&lt;image.PixelMap&gt;): void
**示例:** **示例:**
```js ```js
windowClass.snapshot((err, data) => { windowClass.snapshot((err, pixelMap) => {
if (err.code) { if (err.code) {
console.error('Failed to snapshot window. Cause:' + JSON.stringify(err)); console.error('Failed to snapshot window. Cause:' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber()); console.info('Succeeded in snapshotting window. Pixel bytes number: ' + pixelMap.getPixelBytesNumber());
data.release(); // PixelMap使用完后及时释放内存 pixelMap.release(); // PixelMap使用完后及时释放内存
}); });
``` ```
...@@ -3861,9 +3850,9 @@ scale(scaleOptions: ScaleOptions): void ...@@ -3861,9 +3850,9 @@ scale(scaleOptions: ScaleOptions): void
let obj : window.ScaleOptions = { let obj : window.ScaleOptions = {
x : 2.0, x : 2.0,
y : 1.0, y : 1.0,
pivotX = 0.5; pivotX : 0.5,
pivotY = 0.5; pivotY : 0.5
} };
try { try {
windowClass.scale(obj); windowClass.scale(obj);
} catch (exception) { } catch (exception) {
...@@ -3903,9 +3892,9 @@ let obj : window.RotateOptions = { ...@@ -3903,9 +3892,9 @@ let obj : window.RotateOptions = {
x : 1.0, x : 1.0,
y : 1.0, y : 1.0,
z : 45.0, z : 45.0,
pivotX = 0.5; pivotX : 0.5,
pivotY = 0.5; pivotY : 0.5
} };
try { try {
windowClass.rotate(obj); windowClass.rotate(obj);
} catch (exception) { } catch (exception) {
...@@ -3945,7 +3934,7 @@ let obj : window.TranslateOptions = { ...@@ -3945,7 +3934,7 @@ let obj : window.TranslateOptions = {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
try { try {
windowClass.translate(obj); windowClass.translate(obj);
} catch (exception) { } catch (exception) {
...@@ -3983,7 +3972,7 @@ try { ...@@ -3983,7 +3972,7 @@ try {
```js ```js
let controller = windowClass.getTransitionController(); // 获取属性转换控制器 let controller = windowClass.getTransitionController(); // 获取属性转换控制器
controller.animationForHidden = (context : window.TransitionContext) => { controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -3999,7 +3988,7 @@ controller.animationForHidden = (context : window.TransitionContext) => { ...@@ -3999,7 +3988,7 @@ controller.animationForHidden = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); // 设置动画过程中的属性转换 toWindow.translate(obj); // 设置动画过程中的属性转换
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
...@@ -4114,7 +4103,7 @@ setBackdropBlurStyle(blurStyle: BlurStyle): void ...@@ -4114,7 +4103,7 @@ setBackdropBlurStyle(blurStyle: BlurStyle): void
```js ```js
try { try {
windowClass.setBackdropBlurStyle(window.BlurType.THIN); windowClass.setBackdropBlurStyle(window.BlurStyle.THIN);
} catch (exception) { } catch (exception) {
console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception)); console.error('Failed to set backdrop blur style. Cause: ' + JSON.stringify(exception));
}; };
...@@ -6537,7 +6526,7 @@ completeTransition(isCompleted: boolean): void ...@@ -6537,7 +6526,7 @@ completeTransition(isCompleted: boolean): void
```js ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => { controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -6550,7 +6539,7 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -6550,7 +6539,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
...@@ -6589,7 +6578,7 @@ animationForShown(context: TransitionContext): void ...@@ -6589,7 +6578,7 @@ animationForShown(context: TransitionContext): void
```js ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForShown = (context : window.TransitionContext) => { controller.animationForShown = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -6605,7 +6594,7 @@ controller.animationForShown = (context : window.TransitionContext) => { ...@@ -6605,7 +6594,7 @@ controller.animationForShown = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
...@@ -6635,7 +6624,7 @@ animationForHidden(context: TransitionContext): void ...@@ -6635,7 +6624,7 @@ animationForHidden(context: TransitionContext): void
```js ```js
let controller = windowClass.getTransitionController(); let controller = windowClass.getTransitionController();
controller.animationForHidden = (context : window.TransitionContext) => { controller.animationForHidden = (context : window.TransitionContext) => {
let toWindow = context.toWindow let toWindow = context.toWindow;
animateTo({ animateTo({
duration: 1000, // 动画时长 duration: 1000, // 动画时长
tempo: 0.5, // 播放速率 tempo: 0.5, // 播放速率
...@@ -6651,7 +6640,7 @@ controller.animationForHidden = (context : window.TransitionContext) => { ...@@ -6651,7 +6640,7 @@ controller.animationForHidden = (context : window.TransitionContext) => {
x : 100.0, x : 100.0,
y : 0.0, y : 0.0,
z : 0.0 z : 0.0
} };
toWindow.translate(obj); toWindow.translate(obj);
console.info('toWindow translate end'); console.info('toWindow translate end');
} }
......
# 屏幕错误码 # 屏幕错误码
## 1400001 无效虚拟屏 ## 1400001 无效虚拟屏
### 错误信息 **错误信息**<br>
This is invalid screen. This is invalid screen.
### 错误描述
**错误描述**<br>
当操作无效的虚拟屏时,会报此错误码。 当操作无效的虚拟屏时,会报此错误码。
### 可能原因
**可能原因**
1. 虚拟屏未创建。 1. 虚拟屏未创建。
2. 虚拟屏已销毁。 2. 虚拟屏已销毁。
### 处理步骤
**处理步骤**
1. 在操作虚拟屏前,检查该虚拟屏是否已经存在,确保已创建该虚拟屏。 1. 在操作虚拟屏前,检查该虚拟屏是否已经存在,确保已创建该虚拟屏。
2. 在操作虚拟屏前,检查虚拟屏是否已被销毁,确保其未被销毁,再进行相关操作。 2. 在操作虚拟屏前,检查虚拟屏是否已被销毁,确保其未被销毁,再进行相关操作。
## 1400002 无权限操作 ## 1400002 无权限操作
### 错误信息 **错误信息**<br>
This operation is not access. This operation is not access.
### 错误描述
**错误描述**<br>
当对无操作权限的对象进行操作时,会报此错误码。 当对无操作权限的对象进行操作时,会报此错误码。
### 可能原因
**可能原因**<br>
操作了其它进程的虚拟屏对象。 操作了其它进程的虚拟屏对象。
### 处理步骤
**处理步骤**<br>
请检查是否非法操作了别的进程的对象,删除相关非法操作。 请检查是否非法操作了别的进程的对象,删除相关非法操作。
## 1400003 系统服务工作异常 ## 1400003 系统服务工作异常
### 错误信息 **错误信息**<br>
This window manager service work abnormally. This window manager service work abnormally.
### 错误描述
**错误描述**<br>
当系统服务工作异常时,会报此错误码。 当系统服务工作异常时,会报此错误码。
### 可能原因
**可能原因**
1. 窗口内部服务没有正常启动。 1. 窗口内部服务没有正常启动。
2. 底层图形图像合成渲染异常。 2. 底层图形图像合成渲染异常。
### 处理步骤
**处理步骤**<br>
系统服务内部工作异常,请稍候重试,或者重启设备尝试。 系统服务内部工作异常,请稍候重试,或者重启设备尝试。
# 窗口错误码 # 窗口错误码
## 1300001 重复操作 ## 1300001 重复操作
### 错误信息 **错误信息**<br>
This is repeat operation. This is repeat operation.
### 错误描述
**错误描述**<br>
当进行某些重复操作时,系统会报此错误码。 当进行某些重复操作时,系统会报此错误码。
### 可能原因
**可能原因**<br>
创建的窗口已经存在时,再次创建该窗口会报错。 创建的窗口已经存在时,再次创建该窗口会报错。
### 处理步骤
**处理步骤**<br>
在创建窗口前,检查该窗口是否已经存在,确保为首次创建该窗口。 在创建窗口前,检查该窗口是否已经存在,确保为首次创建该窗口。
## 1300002 窗口状态异常 ## 1300002 窗口状态异常
### 错误信息 **错误信息**<br>
This window state is abnormal. This window state is abnormal.
### 错误描述
**错误描述**<br>
当窗口状态异常,如已被销毁时,操作该窗口,会报此错误码。 当窗口状态异常,如已被销毁时,操作该窗口,会报此错误码。
### 可能原因
**可能原因**<br>
操作窗口时,该窗口已被销毁。 操作窗口时,该窗口已被销毁。
### 处理步骤
**处理步骤**<br>
在对窗口进行操作前,检查该窗口是否存在,确保其未被销毁,再进行相关操作。 在对窗口进行操作前,检查该窗口是否存在,确保其未被销毁,再进行相关操作。
## 1300003 系统服务工作异常 ## 1300003 系统服务工作异常
### 错误信息 **错误信息**<br>
This window manager service work abnormally. This window manager service work abnormally.
### 错误描述
**错误描述**<br>
当系统服务工作异常时,会报此错误码。 当系统服务工作异常时,会报此错误码。
### 可能原因
**可能原因**<br>
窗口内部服务没有正常启动。 窗口内部服务没有正常启动。
### 处理步骤
**处理步骤**<br>
系统服务内部工作异常,请稍候重试,或者重启设备尝试。 系统服务内部工作异常,请稍候重试,或者重启设备尝试。
## 1300004 无权限操作 ## 1300004 无权限操作
### 错误信息 **错误信息**<br>
This operation is not access. This operation is not access.
### 错误描述
**错误描述**<br>
当对无操作权限的对象进行操作时,会报此错误码。 当对无操作权限的对象进行操作时,会报此错误码。
### 可能原因
**可能原因**<br>
操作了其它进程的窗口对象。 操作了其它进程的窗口对象。
### 处理步骤
**处理步骤**<br>
请检查是否非法操作了别的进程的对象,删除相关操作。 请检查是否非法操作了别的进程的对象,删除相关操作。
## 1300005 WindowStage异常 ## 1300005 WindowStage异常
### 错误信息 **错误信息**<br>
This window stage is abnormal. This window stage is abnormal.
### 错误描述
**错误描述**<br>
当WindowStage异常,如已被销毁时,操作该WindowStage,会报此错误码。 当WindowStage异常,如已被销毁时,操作该WindowStage,会报此错误码。
### 可能原因
**可能原因**<br>
操作WindowStage时,该WindowStage已被销毁。 操作WindowStage时,该WindowStage已被销毁。
### 处理步骤
**处理步骤**<br>
在对WindowStage进行操作前,检查该WindowStage是否存在,若已被销毁,请释放该WindowStage下的窗口。 在对WindowStage进行操作前,检查该WindowStage是否存在,若已被销毁,请释放该WindowStage下的窗口。
## 1300006 窗口上下文异常 ## 1300006 窗口上下文异常
### 错误信息 **错误信息**<br>
This window context is abnormal. This window context is abnormal.
### 错误描述
**错误描述**<br>
当窗口上下文异常,如已被销毁时,操作该窗口上下文,会报此错误码。 当窗口上下文异常,如已被销毁时,操作该窗口上下文,会报此错误码。
### 可能原因
**可能原因**<br>
操作窗口上下文时,该窗口上下文已被销毁。 操作窗口上下文时,该窗口上下文已被销毁。
### 处理步骤
**处理步骤**<br>
在对窗口上下文进行操作前,检查该窗口上下文是否存在,确保其未被销毁,再进行相关操作。 在对窗口上下文进行操作前,检查该窗口上下文是否存在,确保其未被销毁,再进行相关操作。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册