1e41f4b71Sopenharmony_ci# Account Subsystem ChangeLog
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## cl.account_os_account.1 Change of Definition and Return Mode of Error Codes
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciTo solve the issues that error code definitions of the account subsystem APIs were inconsistent and that the return mode of the error codes did not comply with relevant specifications of OpenHarmony, the following changes are made and take effect in API version 9 and later:
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci- Added the following unified error code definitions:
8e41f4b71Sopenharmony_ci  - [Account Error Codes](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/errorcodes/errorcode-account.md)
9e41f4b71Sopenharmony_ci  - [App Account Error Codes](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/errorcodes/errorcode-account.md)
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci- Returned an error code in either of the following ways, according to the API type:
12e41f4b71Sopenharmony_ci  - Asynchronous API: An error message is returned via **AsyncCallback** or the **error** object of **Promise**. An error message related to the parameter type or quantity is returned via an exception.
13e41f4b71Sopenharmony_ci  - Synchronous API: An error message is returned via an exception.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci**Change Impacts**
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciThe application developed based on earlier versions needs to adapt the method for returning API error information. Otherwise, the original service logic will be affected.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Key API/Component Changes**
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciThe mentioned changes involve the following APIs:
22e41f4b71Sopenharmony_ci  - class AccountManager
23e41f4b71Sopenharmony_ci    - activateOsAccount(localId: number, callback: AsyncCallback<void>): void;
24e41f4b71Sopenharmony_ci    - removeOsAccount(localId: number, callback: AsyncCallback<void>): void;
25e41f4b71Sopenharmony_ci    - setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean, callback: AsyncCallback<void>): void;
26e41f4b71Sopenharmony_ci    - setOsAccountName(localId: number, localName: string, callback: AsyncCallback<void>): void;
27e41f4b71Sopenharmony_ci    - queryMaxOsAccountNumber(callback: AsyncCallback<number>): void;
28e41f4b71Sopenharmony_ci    - queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>>): void;
29e41f4b71Sopenharmony_ci    - createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback<OsAccountInfo>): void;
30e41f4b71Sopenharmony_ci    - createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void;
31e41f4b71Sopenharmony_ci    - queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo>): void;
32e41f4b71Sopenharmony_ci    - getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>): void;
33e41f4b71Sopenharmony_ci    - setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback<void>): void;
34e41f4b71Sopenharmony_ci    - on(type: 'activate' | 'activating', name: string, callback: Callback<number>): void;
35e41f4b71Sopenharmony_ci    - off(type: 'activate' | 'activating', name: string, callback?: Callback<number>): void;
36e41f4b71Sopenharmony_ci    - isMainOsAccount(callback: AsyncCallback<boolean>): void;
37e41f4b71Sopenharmony_ci    - queryOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback<Array<ConstraintSourceTypeInfo>>): void;
38e41f4b71Sopenharmony_ci  - class UserAuth
39e41f4b71Sopenharmony_ci    - constructor();
40e41f4b71Sopenharmony_ci    - getVersion(): number;
41e41f4b71Sopenharmony_ci    - getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
42e41f4b71Sopenharmony_ci    - getProperty(request: GetPropertyRequest, callback: AsyncCallback<ExecutorProperty>): void;
43e41f4b71Sopenharmony_ci    - setProperty(request: SetPropertyRequest, callback: AsyncCallback<number>): void;
44e41f4b71Sopenharmony_ci    - auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
45e41f4b71Sopenharmony_ci    - authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
46e41f4b71Sopenharmony_ci    - cancelAuth(contextID: Uint8Array): number;
47e41f4b71Sopenharmony_ci  - class PINAuth
48e41f4b71Sopenharmony_ci    - constructor();
49e41f4b71Sopenharmony_ci    - registerInputer(inputer: IInputer): boolean;
50e41f4b71Sopenharmony_ci    - unregisterInputer(authType: AuthType): void;
51e41f4b71Sopenharmony_ci  - class UserIdentityManager
52e41f4b71Sopenharmony_ci    - constructor();
53e41f4b71Sopenharmony_ci    - openSession(callback: AsyncCallback<Uint8Array>): void;
54e41f4b71Sopenharmony_ci    - addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
55e41f4b71Sopenharmony_ci    - updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
56e41f4b71Sopenharmony_ci    - closeSession(): void;
57e41f4b71Sopenharmony_ci    - cancel(challenge: Uint8Array): number;
58e41f4b71Sopenharmony_ci    - delUser(token: Uint8Array, callback: IIdmCallback): void;
59e41f4b71Sopenharmony_ci    - delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void;
60e41f4b71Sopenharmony_ci    - getAuthInfo(callback: AsyncCallback<Array<EnrolledCredInfo>>): void;
61e41f4b71Sopenharmony_ci  - interface IInputData
62e41f4b71Sopenharmony_ci    - onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci**Adaptation Guide**
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ciThe following uses **activateOsAccount** as an example to illustrate the error information processing logic of an asynchronous API:
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci```ts
69e41f4b71Sopenharmony_ciimport account_osAccount from "@ohos.account.osAccount"
70e41f4b71Sopenharmony_cilet accountMgr = account_osAccount.getAccountManager()
71e41f4b71Sopenharmony_cilet callbackFunc = (err) => {
72e41f4b71Sopenharmony_ci  if (err != null) {  // Handle the business error.
73e41f4b71Sopenharmony_ci    console.log("account_osAccount failed, error: " + JSON.stringify(err));
74e41f4b71Sopenharmony_ci  } else {
75e41f4b71Sopenharmony_ci    console.log("account_osAccount successfully");
76e41f4b71Sopenharmony_ci  }
77e41f4b71Sopenharmony_ci}
78e41f4b71Sopenharmony_citry {
79e41f4b71Sopenharmony_ci  accountMgr.activateOsAccount("100", callbackFunc);
80e41f4b71Sopenharmony_ci} catch (err) {  // Process the error that is related to the parameter type.
81e41f4b71Sopenharmony_ci  console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err));
82e41f4b71Sopenharmony_ci}
83e41f4b71Sopenharmony_citry {
84e41f4b71Sopenharmony_ci  accountMgr.activateOsAccount();
85e41f4b71Sopenharmony_ci} catch (err) {  // Process the error that is related to the parameter quantity.
86e41f4b71Sopenharmony_ci  console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err));
87e41f4b71Sopenharmony_ci}
88e41f4b71Sopenharmony_ci```
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ciThe following uses **registerInputer** as an example to illustrate the error information processing logic of a synchronous API:
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci```ts
93e41f4b71Sopenharmony_ciimport account_osAccount from "@ohos.account.osAccount"
94e41f4b71Sopenharmony_cilet pinAuth = new account_osAccount.PINAuth()
95e41f4b71Sopenharmony_citry {
96e41f4b71Sopenharmony_ci    pinAuth.registerInputer({})
97e41f4b71Sopenharmony_ci} catch (err) {  // Process the error that is related to the parameter type.
98e41f4b71Sopenharmony_ci  console.log("account_osAccount failed for incorrect parameter type, error: " + JSON.stringify(err));
99e41f4b71Sopenharmony_ci}
100e41f4b71Sopenharmony_citry {
101e41f4b71Sopenharmony_ci    pinAuth.registerInputer()
102e41f4b71Sopenharmony_ci} catch (err) {  // Process the error that is related to the parameter quantity.
103e41f4b71Sopenharmony_ci  console.log("account_osAccount failed for incorrect parameter number, error: " + JSON.stringify(err));
104e41f4b71Sopenharmony_ci}
105e41f4b71Sopenharmony_ci```
106