jcward / haxe-graphql

Utilities for working with Haxe and GraphQL.
MIT License
23 stars 6 forks source link

When HaxeGenerator throws, we lose error output #35

Closed jcward closed 5 years ago

jcward commented 5 years ago

The following test causes HaxeGenerator to throw:

type Foo {
  age: Int
  name: String
  stars: InvalidTypeTypo
}

type Query {
  get_invalid: Foo
}

query GetInvalidTypedField {
  get_invalid {
    name
    stars
  }
}

While the InvalidTypeTypo error is detected, the query processor throws when it can't lookup the type, which crashes the tool, and the error is never reported.

More generally, the problem is that HaxeGenerator.hx is currently using a mix of both error(msg) and throw msg. Instead, it should standardize on error(), and always ensure those are reported, even when exceptions (expected or unexpected) occur.