Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Thrift user experience, add more assertions. #266

Open
Raynos opened this issue Jan 13, 2016 · 0 comments
Open

Thrift user experience, add more assertions. #266

Raynos opened this issue Jan 13, 2016 · 0 comments

Comments

@Raynos
Copy link
Contributor

Raynos commented Jan 13, 2016

It's easy to get the thrift exceptions wrong, given the following thrift:

service Wat {
    WatResponse wat(
        1: required WatRequest request
    )
    throws (
        1: InvalidRequestException invalid
        2: NotFoundException notFound
    )
}

I might implement the following endpoint

function wat(context, req, head, body, cb) {
  cb(null, {
    ok: false,
    head: null,
    body: { message: 'not found' },
    typeName: 'NotFoundException'
  });
}

This will confusingly break by returning an empty arg3 body.

What should have happened was an exception like:

assert(true, 'Expected typeName to be one of { invalid, notFound }');

cc @kriskowal @breerly

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant