core: refactor error initialization logic

/cc @tmatilai - This includes a test case for the symbol stuff, should
be okay now.