Skip to content

Commit

Permalink
refactor: update error codes and messages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgerardojacinto committed Jan 9, 2024
1 parent b731dd8 commit b46cda2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package com.outsystems.plugins.barcode.model
* Enum class that holds the library's errors.
*/
enum class OSBARCError(val code: Int, val description: String) {
CAMERA_PERMISSION_DENIED_ERROR(7, "Scanning cancelled due to missing camera permissions."),
INVALID_PARAMETERS_ERROR(10, "Scanning parameters are invalid."),
SCAN_CANCELLED_ERROR(6, "Scanning cancelled."),
SCANNING_GENERAL_ERROR(4, "Error while trying to scan code."),
ZXING_LIBRARY_ERROR(11, "There was an error scanning the barcode with ZXing."),
MLKIT_LIBRARY_ERROR(12, "There was an error scanning the barcode with ML Kit.")
SCAN_CANCELLED_ERROR(6, "Couldn't scan because the process was cancelled."),
CAMERA_PERMISSION_DENIED_ERROR(7, "Couldn't scan because camera access wasn't provided. Check your camera permissions and try again."),
INVALID_PARAMETERS_ERROR(8, "Scanning parameters are invalid."),
ZXING_LIBRARY_ERROR(9, "There was an error scanning the barcode with ZXing."),
MLKIT_LIBRARY_ERROR(10, "There was an error scanning the barcode with ML Kit.")
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ScanCodeTests {
private const val SCAN_REQUEST_CODE = 112
private const val INVALID_REQUEST_CODE = 113
private const val INVALID_RESULT_CODE = 9
private const val GENERAL_ERROR_CODE = 4
private const val SCAN_RESULT = "scanResult"
private const val RESULT_CODE = "myCode"
}
Expand Down Expand Up @@ -168,7 +169,7 @@ class ScanCodeTests {
Mockito.doReturn(null).`when`(mockBundle).getString(SCAN_RESULT)

val barcodeController = OSBARCController()
barcodeController.handleActivityResult(SCAN_REQUEST_CODE, INVALID_RESULT_CODE, mockIntent,
barcodeController.handleActivityResult(SCAN_REQUEST_CODE, GENERAL_ERROR_CODE, mockIntent,
{
fail()
},
Expand Down

0 comments on commit b46cda2

Please sign in to comment.