engines/sg: improve error handling