目录

ArkTS API Error Codes

This section describes only module-specific error codes. For details about universal error codes, please refer to Universal Error Codes.

1000500001 Internal Error

Scan Kit reports different error information based on the actual error cause. The details are as follows:

[h2]Failed to encode

Error Message

Internal error. Failed to encode.

Error Description

Failed to generate the barcode image.

Possible Causes

An algorithm error occurs during barcode image generation.

Solution

Call the barcode image generation API createBarcode again.

[h2]Failed to decode

Error Message

Internal error. Failed to decode.

Error Description

Failed to recognize barcodes in an image.

Possible Causes

An algorithm error occurs during barcode recognition in an image.

Solution

Call the decode API for barcode recognition in an image again.

[h2]Failed to decode image

Error Message

Internal error. Failed to decode image.

Error Description

Failed to recognize barcodes from image data.

Possible Causes

An algorithm error occurs during barcode recognition from image data.

Solution

Call the decodeImage API for barcode recognition from image data again.

[h2]Failed to create pixelMap

Error Message

Internal error. Failed to create pixelMap.

Error Description

Failed to create pixelMap during barcode image generation.

Possible Causes

The logic for the system to create an image is abnormal.

Solution

Call the barcode image generation API createBarcode again.

[h2]Failed to read file

Error Message

Internal error. Failed to read file.

Error Description

Failed to read the passed image path during barcode recognition in an image.

Possible Causes

The URI passed by the developer is invalid.

Solution

Check the passed URI.

[h2]Get context failed

Error Message

Internal error. Get context failed.

Error Description

Failed to obtain the system context during barcode scanning by default UI.

Possible Causes

The passed context is incorrect.

Solution

Check the input parameter context by referring to Obtaining UIAbilityContext.

[h2]Get UI content failed

Error Message

Internal error. Get UI content failed.

Error Description

Failed to obtain the UI content during barcode scanning by default UI.

Possible Causes

The passed context is incorrect. As a result, the UI content fails to be obtained.

Solution

Check the input parameter context by referring to Obtaining UIAbilityContext.

[h2]Get callback failed

Error Message

Internal error. Get callback failed.

Error Description

Failed to obtain the callback.

Possible Causes

The external callback is abnormal.

Solution

Check the callback input parameter.

[h2]This interface must be invoked after the customScan.start interface

Error Message

Internal error. This interface must be invoked after the customScan.start interface.

Error Description

The API call sequence is incorrect. The start API is not called before the current API is called.

Possible Causes

APIs are not called based on the service process. For example, the getFlashLightStatus API is directly called without calling the start API first.

Solution

Adjust the API call sequence. For details, please refer to Flowchart of scanning on a custom UI. For example, call the start API and then the getFlashLightStatus API.

[h2]This interface cannot be used after the camera session is paused

Error Message

Internal error. This interface cannot be used after the camera session is paused.

Error Description

The API call sequence is incorrect. The stop API is called before the current API.

Possible Causes

APIs are not called based on the service process. For example, the getFlashLightStatus API is called after the stop API is called.

Solution

Adjust the API call sequence. For details, please refer to Flowchart of scanning on a custom UI. For example, before calling the getFlashLightStatus API, ensure that the stop API is not called.

[h2]ScanOption is null, please call customScan.init first

Error Message

Internal error. ScanOption is null, please call customScan.init first.

Error Description

The API call sequence is incorrect. The init API is not called before the start API.

Possible Causes

The init API is not called before the start API.

Solution

Adjust the API call sequence. For details, please refer to Flowchart of scanning on a custom UI. Call the init API before calling the start API.

[h2]The interface can't be used in promise interface

Error Message

Internal error. The interface can't be used in promise interface.

Error Description

This API cannot be called in the promise mode of start.

Possible Causes

The rescan API is called in the promise mode of start.

Solution

Use the callback mode of start to call the rescan API.

[h2]CustomScan stop session failed

Error Message

Internal error. CustomScan stop session failed.

Error Description

Camera error.

Possible Causes

Failed to stop the barcode scanning camera stream.

Solution

Check whether the barcode scanning camera stream has been started. If not, create a barcode scanning camera stream again. Check whether the barcode scanning camera stream has been stopped.

[h2]CustomScan release failed

Error Message

Internal error. CustomScan release failed.

Error Description

Camera error.

Possible Causes

Failed to release the barcode scanning camera stream.

Solution

Check whether the barcode scanning camera stream has been started. If not, create a barcode scanning camera stream again. Check whether the barcode scanning camera stream has been released.

[h2]Open camera flash failed, flashlight is not available

Error Message

Internal error. Open camera flash failed, flashlight is not available.

Error Description

Failed to turn on the flash light.

Possible Causes

The flash light is unavailable.

Solution

Check whether the flash light of the device is normal.

[h2]Close camera flash failed, flashlight is not available

Error Message

Internal error. Close camera flash failed, flashlight is not available.

Error Description

Failed to turn off the flash light.

Possible Causes

The flash light is unavailable.

Solution

Check whether the flash light of the device is normal.

[h2]Camera setZoom failed

Error Message

Internal error. Camera setZoom failed.

Error Description

Failed to set the zoom ratio.

Possible Causes

The camera is abnormal.

Solution

Check whether the barcode scanning camera stream has been started. If not, create a barcode scanning camera stream again.

[h2]Camera getZoom failed

Error Message

Internal error. Camera getZoom failed.

Error Description

Failed to obtain the zoom ratio.

Possible Causes

The camera is abnormal.

Solution

Check whether the barcode scanning camera stream has been started. If not, create a barcode scanning camera stream again.

[h2]Camera setFocusPoint failed

Error Message

Internal error. Camera setFocusPoint failed.

Error Description

Failed to set the camera focal point.

Possible Causes

The camera is abnormal.

Solution

Check whether the barcode scanning camera stream has been started. If not, create a barcode scanning camera stream again.

[h2]Reset focus mode failed

Error Message

Internal error. Reset focus mode failed.

Error Description

Failed to set the continuous autofocus mode.

Possible Causes

The camera is abnormal.

Solution

Check whether the barcode scanning camera stream has been started. If not, create a barcode scanning camera stream again.

[h2]Camera config captureSession failed

Error Message

Internal error. Camera config captureSession failed.

Error Description

The camera is abnormal.

Possible Causes

Failed to configure the stream for the camera.

Solution

Try to release the barcode scanning camera stream and then create the service again.

[h2]Camera create cameraManager failed

Error Message

Internal error. Camera create cameraManager failed.

Error Description

The camera is abnormal.

Possible Causes

Failed to create cameraManager.

Solution

Try to release the barcode scanning camera stream and then create the service again.

[h2]Camera create camera session failed

Error Message

Internal error. Camera create camera session failed.

Error Description

The camera is abnormal.

Possible Causes

Failed to create a session.

Solution

Try to release the barcode scanning camera stream and then create the service again.

[h2]Camera restart camera session failed

Error Message

Internal error. Camera restart camera session failed.

Error Description

The camera is abnormal.

Possible Causes

Failed to restart the camera.

Solution

Try to release the barcode scanning camera stream and then create the service again.

[h2]Camera create preview output failed

Error Message

Internal error. Camera create preview output failed.

Error Description

The camera is abnormal.

Possible Causes

Failed to create a preview stream.

Solution

Try to release the barcode scanning camera stream and then create the service again.

[h2]Camera get supported output capability failed

Error Message

Internal error. Camera get supported output capability failed.

Error Description

The camera is abnormal.

Possible Causes

Failed to obtain the output capability supported by a specified camera.

Solution

Try to release the barcode scanning camera stream and then create the service again.

[h2]Capability not supported. Failed to call the API due to limited device capabilities

Error Message

Internal error. Capability not supported. Failed to call the API due to limited device capabilities.

Error Description

The device does not support this API. Therefore, it cannot be called properly.

Possible Causes

The device supports the SysCap associated with the API but does not support the API itself.

Solution

Avoid using this API on the device. Alternatively, implement conditional checks in your code to mitigate the impacts arising from the app running on different devices, particularly under abnormal circumstances.

1000500002 Scanning Canceled by User

Error Message

The user canceled the barcode scanning.

Error Description

The user cancels the scanning.

Possible Causes

The user taps the close button or swipes to cancel the scanning on the default screen.

Solution

This error code is returned when startScanForResult is used. Handle the service process after the user cancels the scanning on the default screen based on the application scenario.