Skip to content

Conversation

@benvinegar
Copy link
Contributor

cc @getsentry/javascript

@benvinegar
Copy link
Contributor Author

Refs #435

Copy link
Contributor

@LewisJEllis LewisJEllis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from one comment

src/raven.js Outdated


function isOnlyOneTruthy(a, b) {
return a && !b || b && !a;
Copy link
Contributor

@LewisJEllis LewisJEllis Feb 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this alternative function body:

return !!(!!a ^ !!b);

The xor operator makes it more obvious what's going on IMO, and this will always return a boolean; current version has some edge cases where it won't like isOnlyOneTruthy('', '') (returns empty string). Or if we're cool with always returning 0 or 1 instead of a boolean, we can further simplify to !!a ^ !!b.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, doing it.

Copy link
Contributor

@MaxBittker MaxBittker Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about !!a != !!b?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about !!a != !!b

Are they equivalent?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think green is the best color for bikesheds

@benvinegar
Copy link
Contributor Author

Integration tests incoming.

@benvinegar benvinegar merged commit cb87941 into master Feb 24, 2017
@benvinegar benvinegar deleted the less-dupes branch February 24, 2017 18:05
function isSameException(ex1, ex2) {
if (isOnlyOneTruthy(ex1, ex2))
return false;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self/being paranoid - do we want to nullcheck values here first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We assemble these objects ourselves, and other pieces of the code make the same assumption so I feel it's safe:

e.g. here's _trimPacket:

    _trimPacket: function(data) {
        // For now, we only want to truncate the two different messages
        // but this could/should be expanded to just trim everything
        var max = this._globalOptions.maxMessageLength;
        if (data.message) {
            data.message = truncate(data.message, max);
        }
        if (data.exception) {
            var exception = data.exception.values[0];
            exception.value = truncate(exception.value, max);
        }

        return data;
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants