Handle context creation error

Check context creation return value and act accordingly.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>