Error Codes


let delegate: AsleepDebugLoggerDelegate = self
protocol AsleepDebugLoggerDelegate {
    func didPrint(message: String)
Property NameTypeDescription
messageStringLog message


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


401UnauthorizedUnauthorizedCOMMONClient Handling
401Unauthorizedinvalid user idCOMMONClient Handling
403Plan is expiredPlan is expiredCOMMONSDK Stop
403Rate limit exceededRate limit exceededCOMMONSDK Stop
403Quota exceededQuota exceededCOMMONSDK Stop
400Bad RequestInvalid callback urlTRACKINGClient Handling
400Bad Request[WARNING] Invalid session end time. format(YYYY-MM-DDTHH:mm:ssz), 'session_end_time' must always be greater than 'session_start_time’TRACKINGSDK Handling
403Forbiddenthe sleep session is already closedTRACKINGSDK Stop
404Not Foundsession does not exist.TRACKINGClient Handling
409Conflictprevious sleep session is not closed yetTRACKINGSDK Stop
422Validation ErrorInvalid parameterTRACKINGSDK Handling
422Unprocessable EntityInvalid parameter.TRACKINGSDK Handling
400Bad Requestinvalid timezoneREPORTClient Handling
400Unprocessable EntityThe format of sleep session id {session_id} is not validREPORTClient Handling
401UnauthorizedThe api key is not providedREPORTClient Handling
404Not FoundUnable to find the sleep session of id {session_id}REPORTClient 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.