Skip to content

Commit

Permalink
Merge pull request #237 from telefonicaid/fix/log_get_protocol
Browse files Browse the repository at this point in the history
Fix/log get protocol
  • Loading branch information
fgalan authored Mar 5, 2021
2 parents 0d655fe + 77ada79 commit 7f269e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fix: log about getProtocol result
- Fix: ensure protocol exists before remove it (#234)
- Fix: print URI in logs about redirection error (#232)
- Upgrade NodeJS version from 10 to 12 in Dockerfile due to Node 10 End-of-Life
Expand Down
9 changes: 5 additions & 4 deletions lib/services/protocolData.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ function getProtocol(protocol, callback) {
};
const query = Protocol.model.find(condition).sort();

query.exec(function (error, protocol) {
if (!error && protocol && protocol.length === 1) {
callback(null, protocol[0]);
query.exec(function (error, protocolFound) {
if (!error && protocolFound && protocolFound.length === 1) {
callback(null, protocolFound[0]);
} else if (error) {
callback(error);
} else {
callback(new errors.ProtocolNotFound(protocol));
const resource = 'n/a';
callback(new errors.ProtocolNotFound(resource, protocol));
}
});
}
Expand Down

0 comments on commit 7f269e1

Please sign in to comment.