Fix Indent and rebase some function

1.	Indent use four space
2.	Use raise to catch error and use lendException to flash errors.