Check file existence before loading it and check errors

To avoid no such file or directory error or value error.

Closes-bug: #1258457

Change-Id: I8973a90b84a039cce4445cd5164f35368897e82e
Merge "Check file existence before loading it and check errors"