<commit_before>"use strict";

import Guard from './Guard';

class EventContext {
    constructor(modelId, eventType, event) {
        Guard.isString(modelId, "The modelId should be a string");
        Guard.isString(eventType, "The eventType should be a string");
        Guard.isDefined(event, "The event should be defined");
        this._modelId = modelId;
        this._eventType = eventType;
        this._event = event;
        this._isCanceled = false;
        this._isCommitted = false;
    }
    get isCanceled() {
        return this._isCanceled;
    }
    get isCommitted() {
        return this._isCommitted;
    }
    get modelId() {
        return this._modelId;
    }
    get event() {
        return this._event;
    }
    get eventType() {
        return this._eventType;
    }
    cancel() {
        if(!this._isCanceled) {
            this._isCanceled = true;
        } else {
            throw 'event is already canceled';
        }
    }
    commit() {
        if(!this._isCommitted) {
            this._isCommitted = true;
        } else {
            throw 'event is already committed';
        }
    }
}

export default EventContext;<commit_msg>Throw an error, not just a plain string<commit_after>"use strict";

import Guard from './Guard';

class EventContext {
    constructor(modelId, eventType, event) {
        Guard.isString(modelId, "The modelId should be a string");
        Guard.isString(eventType, "The eventType should be a string");
        Guard.isDefined(event, "The event should be defined");
        this._modelId = modelId;
        this._eventType = eventType;
        this._event = event;
        this._isCanceled = false;
        this._isCommitted = false;
    }
    get isCanceled() {
        return this._isCanceled;
    }
    get isCommitted() {
        return this._isCommitted;
    }
    get modelId() {
        return this._modelId;
    }
    get event() {
        return this._event;
    }
    get eventType() {
        return this._eventType;
    }
    cancel() {
        if(!this._isCanceled) {
            this._isCanceled = true;
        } else {
            throw new Error('event is already cancelled');
        }
    }
    commit() {
        if(!this._isCommitted) {
            this._isCommitted = true;
        } else {
            throw 'event is already committed';
        }
    }
}

export default EventContext;
{'fraction_non_alphanumeric': 0.10395622895622895, 'fraction_numerical': 0.0, 'mean_word_length': 1.9237392373923738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2839079', 'n_tokens_mistral': 686, 'n_tokens_neox': 693, 'n_words': 175}