diff --git a/README.md b/README.md index 24dbcbf78..237541741 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

protobuf.js

-

donate ❤

+

donate ❤

**Protocol Buffers** are a language-neutral, platform-neutral, extensible way of serializing structured data for use in communications protocols, data storage, and more, originally designed at Google ([see](https://developers.google.com/protocol-buffers/)). @@ -346,7 +346,7 @@ Documentation * [Frequently asked questions](https://github.com/dcodeIO/protobuf.js/wiki) on our wiki #### Community -* [Questions and answers](http://stackoverflow.com/search?q=protobuf.js) on StackOverflow +* [Questions and answers](http://stackoverflow.com/search?tab=newest&q=protobuf.js) on StackOverflow Command line ------------ diff --git a/src/encoder.js b/src/encoder.js index e7b304f94..b2586c733 100644 --- a/src/encoder.js +++ b/src/encoder.js @@ -49,12 +49,13 @@ function encoder(mtype) { // "when a message is serialized its known fields should be written sequentially by field number" var fields = /* initializes */ mtype.fieldsArray; + /* istanbul ignore else */ if (encoder.compat) fields = fields.slice().sort(compareFieldsById); for (var i = 0; i < fields.length; ++i) { var field = fields[i].resolve(), - index = encoder.compat ? mtype._fieldsArray.indexOf(field) : i; + index = encoder.compat ? mtype._fieldsArray.indexOf(field) : /* istanbul ignore next */ i; if (field.partOf) // see below for oneofs continue; var type = field.resolvedType instanceof Enum ? "uint32" : field.type, diff --git a/tests/other_protocolerror.js b/tests/other_protocolerror.js index 076cae5c1..3030a6d47 100644 --- a/tests/other_protocolerror.js +++ b/tests/other_protocolerror.js @@ -27,6 +27,8 @@ tape.test("a protocol error", function(test) { test.fail("should be thrown if a message is missing required fields"); } catch (e) { test.ok(e instanceof ProtocolError, "should be thrown if a message is missing required fields"); + test.ok(e.message, "should have an error message"); + test.ok(e.stack, "should have a stack trace"); test.equal(e.name, "ProtocolError", "should have the correct name"); test.same(e.instance, { foo: 2