Skip to content

Commit

Permalink
Log error returned by PBS (prebid#2335)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiminpanchal27 authored and dluxemburg committed Jul 17, 2018
1 parent e237109 commit 466252b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ const LEGACY_PROTOCOL = {
if (bidder.no_cookie) {
doBidderSync(bidder.usersync.type, bidder.usersync.url, bidder.bidder);
}
if (bidder.error) {
utils.logWarn(`Prebid Server returned error: '${bidder.error}' for ${bidder.bidder}`);
}
});
}

Expand Down
31 changes: 31 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,15 @@ const RESPONSE_OPENRTB_VIDEO = {
},
};

const RESPONSE_UNSUPPORTED_BIDDER = {
'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5',
'status': 'OK',
'bidder_status': [{
'bidder': '33Across',
'error': 'Unsupported bidder'
}]
};

describe('S2S Adapter', () => {
let adapter,
addBidResponse = sinon.spy(),
Expand Down Expand Up @@ -559,6 +568,7 @@ describe('S2S Adapter', () => {

describe('response handler', () => {
let server;
let logWarnSpy;

beforeEach(() => {
server = sinon.fakeServer.create();
Expand All @@ -569,6 +579,7 @@ describe('S2S Adapter', () => {
sinon.stub(utils, 'getBidRequest').returns({
bidId: '123'
});
logWarnSpy = sinon.spy(utils, 'logWarn');
});

afterEach(() => {
Expand All @@ -578,6 +589,7 @@ describe('S2S Adapter', () => {
utils.insertUserSyncIframe.restore();
utils.logError.restore();
cookie.cookieSet.restore();
logWarnSpy.restore();
});

// TODO: test dependent on pbjs_api_spec. Needs to be isolated
Expand Down Expand Up @@ -810,6 +822,25 @@ describe('S2S Adapter', () => {
expect(response).to.have.property('adId', '123');
expect(response).to.have.property('cpm', 10);
});

it('should log warning for unsupported bidder', () => {
server.respondWith(JSON.stringify(RESPONSE_UNSUPPORTED_BIDDER));

const s2sConfig = Object.assign({}, CONFIG, {
bidders: ['33Across']
});

const _config = {
s2sConfig: s2sConfig,
}

config.setConfig(_config);
config.setConfig({s2sConfig: CONFIG});
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
server.respond();

sinon.assert.calledOnce(logWarnSpy);
});
});

describe('s2sConfig', () => {
Expand Down

0 comments on commit 466252b

Please sign in to comment.