Error Codes
Asleep.setDebugLoggerDelegate()
let delegate: AsleepDebugLoggerDelegate = self
Asleep.setDebugLoggerDelegate(self)
protocol AsleepDebugLoggerDelegate {
func didPrint(message: String)
}
Property Name | Type | Description |
---|---|---|
message | String | Log message |
Asleep.AsleepError
enum AsleepError: Error {
case unknown(systemError: Error)
case shouldResume
case over24hours
case audioInitializationFailed
case unsupportedInDeveloperMode
case cannotActivateInBackground
case startTrackingNetworkFail(code: Int, message: String?)
case stopTrackingNetworkFail(code: Int, message: String?)
case responseResult(endpoint: String)
case httpStatus(code: Int, errorCode: Int, message: String?)
}
unknown: Unknown system error
- systemError: Error - error due to system
shouldResume: unable to resume microphone recording after interrupt
over24Hours: recording exceeded 24 hours and is forcibly stopped
- The Asleep SDK does not support sleep tracking exceeding 24 hours.
audioInitializationFailed: Audio configuration error
- iOS device audio initialization error (
2.2.0<=SDK
)- Call "createSleepTrackingManager()" again for Audio setting initialization
cannotActivateInBackground: Failed to resume the microphone after the interrupt ends
- If this error occurs, notify the user (e.g., through a notification), and run Asleep.SleepTrackingManager.resumeTracking() while the app is in the foreground.
2.4.5<=SDK
startTrackingNetworkFail: occurred Network error during startTracking initialization
- code: http codes of 400 and above
- message: String type - description of the error
stopTrackingNetworkFail: occurred Network error during stopTracking
- code: http codes of 400 and above
- message: String type - description of the error
responseResult: error due to api reponse result value
- endpoint - The endpoint where the problem occurred
httpStatus: http error
- code: Int - 400 or more http code
- errorCode: Int - not using
- message: String - error reason explanation
HTTP Status code
State: COMMON, INIT, TRACKING, REPORT
Code | Type | Description | State | Handling |
---|---|---|---|---|
401 | Unauthorized | Unauthorized | COMMON | Client Handling |
401 | Unauthorized | invalid user id | COMMON | Client Handling |
403 | Plan is expired | Plan is expired | COMMON | SDK Stop |
403 | Rate limit exceeded | Rate limit exceeded | COMMON | SDK Stop |
403 | Quota exceeded | Quota exceeded | COMMON | SDK Stop |
400 | Bad Request | Invalid callback url | TRACKING | Client Handling |
400 | Bad Request | [WARNING] Invalid session end time. format(YYYY-MM-DDTHH:mm:ssz), 'session_end_time' must always be greater than 'session_start_time’ | TRACKING | SDK Handling |
403 | Forbidden | the sleep session is already closed | TRACKING | SDK Stop |
404 | Not Found | session does not exist. | TRACKING | Client Handling |
409 | Conflict | previous sleep session is not closed yet | TRACKING | SDK Stop |
422 | Validation Error | Invalid parameter | TRACKING | SDK Handling |
422 | Unprocessable Entity | Invalid parameter. | TRACKING | SDK Handling |
400 | Bad Request | invalid timezone | REPORT | Client Handling |
400 | Unprocessable Entity | The format of sleep session id {session_id} is not valid | REPORT | Client Handling |
401 | Unauthorized | The api key is not provided | REPORT | Client Handling |
404 | Not Found | Unable to find the sleep session of id {session_id} | REPORT | Client Handling |
Definition for SDK Error Handling (From 2.1.2 and later)
Definition of SDK Segment Operation
- Init (initAsleepConfig) : SDK Initialization State
- Tracking (SleepTrackingManager): Audio recording environment and server communication protocol management for sleep monitoring
- Report (Reports): Request sleep monitoring results
Error Case Definition
- SDK Stop: Termination process within the SDK. The SDK needs to be restarted for a new start because it is terminated internally. Depending on the status of the SDK, the session and audio recording function are terminated by itself. You need to start from the "initAsleepConfig" request to activate the SDK
- SDK Handling: The SDK updates the error internally and performs the next action. If you want to terminate after receiving an error, you need to handle it depending on the state of the SDK call. To terminate the SDK, you need to call stopTracking only in the Tracking state, and no separate processing is required in other sections
- Client Handling: An error that needs to be handled by the client. Used for error checking during development.
- Do not used: 현재 버전에서 사용되고 있지 않는 에러
Error Handling Classification
- The error codes that commonly occur when using the SDK are marked in red. The error codes that are crossed out have a low probability of occurring.
Updated 6 months ago