js: Remove most goto error handling

This is C++, we have RAII, so while "goto out" is a good pattern in C if
you are not using g_autoptr, it's not a good pattern in our code. This
removes most goto error handling in favour of RAII or splitting
non-cleanup parts out to a second function. There are still a few
instances of it left, that will require more extensive refactoring.
14 jobs for november-maintenance in 2 minutes and 34 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Source Check
passed #518830
build_recommended

00:01:19

passed #518831
cppcheck

00:00:26

passed #518832
cpplint

00:01:02

 
  Test
passed #518834
build_maximal

00:01:10

passed #518835
build_minimal

00:00:56

passed #518833
sanitizer_gcc

00:01:14

 
  Manual
manual #518836
allowed to fail manual
codequality
manual #518837
allowed to fail manual
coverage
manual #518839
allowed to fail manual
installed_tests
manual #518838
allowed to fail manual
sanitizer_clang
manual #518840
allowed to fail manual
valgrind
manual #518843
allowed to fail manual
zeal_11
manual #518841
allowed to fail manual
zeal_2
manual #518842
allowed to fail manual
zeal_4