Error Handling
You can handle generic error situations in your application.
The Tizen API is mandatory for Tizen TV and IoT profiles, which means that it is supported on all TV and IoT devices. All mandatory APIs are supported on the Tizen emulators.
The main error handling features of the Tizen API include the following:
-
Exception handling
You can enable the Tizen APIs to throw errors synchronously with the
WebAPIExceptioninterface (in TV applications), or return errors in the error event handlers of asynchronous methods with theWebAPIErrorinterface (in TV applications).Note
Do not use the
codeattribute of theWebAPIExceptioninterface to distinguish errors, because the code of the exception object is set to0for new error types that are not defined in DOMException. -
Generic event handling
You can handle the results of asynchronous operations with generic events. The operations can implemented using the
SuccessCallback(in TV applications) andErrorCallback(in TV applications) event handlers of the Tizen API.
Use the generic Event Handlers
Learning how to use generic, predefined event handlers allows you handle application operations and errors efficiently, follow these steps:
-
The generic
onSuccess()event handler of theSuccessCallBackinterface (in TV applications) can be used with methods that do not require a return value when successful.In this example, the event handler is used to stop a running application with the
kill()method of theApplicationinterface (in TV applications):function onSuccess() { console.log('Application terminated successfully'); } tizen.application.kill(ctxIDToKill, onSuccess); -
The generic
onError()event handler of theErrorCallBackinterface (in TV applications) can be used with methods that only require an error as an input parameter in the error callback.In this example, the event handler is used to handle possible errors with the
getCalendars()method of theCalendarManagerinterface:function errorCallback(error) { console.log('The following error occurred: ' + error.name); } tizen.calendar.getCalendars('EVENT', calendarListCallback, errorCallback);
Related Information
- Dependencies
- Tizen 3.0 and Higher for TV
- API References