ErrorController
Variables
| Name | Description | Type | Default | Variable Type |
|---|
| DEFAULT_CODE | เลข code เพื่อระบุ error | Int | 400 | const val |
| CODE | เลข code เพื่อระบุ error สามารถแก้ไขได้ เพื่อเปลี่ยนค่า code | Int | DEFAULT_CODE | var |
Method Overview
| Name | Description | Return |
|---|
| showErrorLog() | เป็นการแสดง Log message ใน console โดยจะมี format ตาม Error String ที่กำหนดของ AtlasX | Int |
| getErrorString() | String ที่เป็น format error ของ AtlasX | String |
| showErrorInAlert() | แสดง AlertDialog ที่มี format ของรายละเอียดเป็นแบบ AltlasX | Unit |
Method Details
fun showErrorLog(message: String , code: Int = CODE) : Int
เป็นการแสดง Log message ใน console โดยจะมี format ตาม Error String ที่กำหนดของ AtlasX
Parameters
| Name | Description | Type | Default |
|---|
| message | รายละเอียดที่ต้องการแสดงใน Log | String | |
| code | เลข code ที่ต้องการแสดง | Int | CODE |
Returns
| Type | Description |
|---|
| Int | Return Log value |
fun getErrorString(message: String , code: Int = CODE) : String
เป็นการแสดง message String โดยจะมี format ตาม Error String ที่กำหนดของ AtlasX คือ “AtlasX Code: {เลข code ของเรา} : {รายละเอียดที่ต้องการแสดง}” เช่น getErrorString(“Number Format Error”) จะได้ String error ออกมาคือแ AtlasX Code: 400 : Number Format Error
Parameters
| Name | Description | Type | Default |
|---|
| message | รายละเอียดที่ต้องการแสดง | String | |
| code | เลข code ที่ต้องการแสดง | Int | CODE |
Returns
| Type | Description |
|---|
| String | Return String ที่บอก error ตาม format ของ AtlasX |
fun showErrorInAlert(context: Context , message: String , code : Int = CODE)
แสดง AlertDialog ที่มี format ของรายละเอียดเป็นแบบ AltlasX
Parameters
| Name | Description | Type | Default |
|---|
| context | context ของ fragment หรือ activity ที่จะใช้งาน | Context | |
| message | รายละเอียดที่ต้องการแสดง | String | |
| code | เลข code ที่ต้องการแสดง | Int | CODE |