Added better error-handling

Signed-off-by: BrotherEdison <brotheredison@outlook.com>