Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS Errors: Remove the content headers from the JS Errors API #3306

Merged
merged 2 commits into from
Feb 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions catch-js-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@
params = 'client_id=39911&client_secret=cOaYKdrkgXz8xY7aysv4fU6wL6sK5J8a6ojReEIAPwggsznj4Cb6mW0nffTxtYT8&error=';
params += encodeURIComponent( JSON.stringify( savedErrors ) );

xhr.setRequestHeader( 'Content-length', params.length );
xhr.setRequestHeader( 'Connection', 'close' );
xhr.send( params );

savedErrors = [];
}
}

function errorToPlainObject( error ) {
var simpleObject = {};
Object.getOwnPropertyNames( error ).forEach( function( key ) {
simpleObject[ key ] = error[ key ];
} );
return simpleObject;
}

function handleError( error ) {
var canSendNow;

Expand All @@ -52,7 +58,7 @@

// add the message to the pack and reset flush timeout
clearTimeout( packTimeout );
savedErrors.push( error );
savedErrors.push( errorToPlainObject( error ) );

// if we can send the pack now, let's do it
if ( canSendNow ) {
Expand Down