Error

ErrorController

Variables

NameDescriptionTypeDefaultVariable Type
DEFAULT_CODEเลข code เพื่อระบุ errorInt400const val
CODEเลข code เพื่อระบุ error สามารถแก้ไขได้ เพื่อเปลี่ยนค่า codeIntDEFAULT_CODEvar

Method Overview

NameDescriptionReturn
showErrorLog()เป็นการแสดง Log message ใน console โดยจะมี format ตาม Error String ที่กำหนดของ AtlasXInt
getErrorString()String ที่เป็น format error ของ AtlasXString
showErrorInAlert()แสดง AlertDialog ที่มี format ของรายละเอียดเป็นแบบ AltlasXUnit

Method Details

fun showErrorLog(message: String , code: Int = CODE) : Int

เป็นการแสดง Log message ใน console โดยจะมี format ตาม Error String ที่กำหนดของ AtlasX

Parameters

NameDescriptionTypeDefault
messageรายละเอียดที่ต้องการแสดงใน LogString
codeเลข code ที่ต้องการแสดงIntCODE

Returns

TypeDescription
IntReturn 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

NameDescriptionTypeDefault
messageรายละเอียดที่ต้องการแสดงString
codeเลข code ที่ต้องการแสดงIntCODE

Returns

TypeDescription
StringReturn String ที่บอก error ตาม format ของ AtlasX
fun showErrorInAlert(context: Context , message: String , code : Int = CODE)

แสดง AlertDialog ที่มี format ของรายละเอียดเป็นแบบ AltlasX

Parameters

NameDescriptionTypeDefault
contextcontext ของ fragment หรือ activity ที่จะใช้งานContext
messageรายละเอียดที่ต้องการแสดงString
codeเลข code ที่ต้องการแสดงIntCODE