<commit_before>
## Intro

*Common Exception* is a cross-language standard for representing an exception as a JSON object.

All fields are optional, and setting a field to <code>null</code> is considered equivalent to omitting it.

<pre>
{
    "name": "...",
    "message": "...",
    "stack": [
        {// most recent stack frame first
            "file_name": "",
            "file_path": "..."
            "file_url": "..."
            "file_sha1": "",        // hex
            "line_number": 100,     // 1-based
            "column_number": 23,    // 1-based
            "byte_offset_start": ,  // #bytes before relevant part
            "byte_offset": ,        // in [byte_offset_start, byte_offset_end]
            "byte_offset_end": ,    // byte_offset_start + len(relevant part)
            "scope_name": "",
            "line": "...line 100...",
            "lines_before": [..., "...98...", "...99..."],
            "lines_after": ["...101...", ...],
...
</pre>


This lets powerful open-source exception servers, e.g.

* [exception-server](https://github.com/andrewschaaf/exception-server)

and JavaScript widgets, e.g.

* exception-server's ExceptionWidget

focus on including awesome features, rather than a batallion of parsers.

## Integration Overview

### Python
<pre>
import common_exception
...
ce = common_exception.fromExceptionText(text)
...
except Exception:
    ce = common_exception.fromCurrentException()
</pre>

* TODO: implement this.

### Ruby

TODO

### JavaScript (NodeJS)
<pre>
var common_exception = require('common_exception');
...
var ce = common_exception.fromBrowserException(e);
...
catch(e) {
    var ce = common_exception.fromNodeException(e);
</pre>

### JavaScript (Browser)<commit_msg>Added "locals" to spec<commit_after>
## Intro

*Common Exception* is a cross-language standard for representing an exception as a JSON object.

All fields are optional, and setting a field to <code>null</code> is considered equivalent to omitting it.

<pre>
{
    "name": "...",
    "message": "...",
    "stack": [
        {// most recent stack frame first
            "file_name": "",
            "file_path": "..."
            "file_url": "..."
            "file_sha1": "",        // hex
            "line_number": 100,     // 1-based
            "column_number": 23,    // 1-based
            "byte_offset_start": ,  // #bytes before relevant part
            "byte_offset": ,        // in [byte_offset_start, byte_offset_end]
            "byte_offset_end": ,    // byte_offset_start + len(relevant part)
            "scope_name": "",
            "line": "...line 100...",
            "lines_before": [..., "...98...", "...99..."],
            "lines_after": ["...101...", ...],
            "locals": {
                // Values intended to be human-readable, not machine-readable
                // Represent values as strings however you see fit, e.g.
                "i": "1729",
                "s": "'9000-char unicode gets trunca'...",
                "s": "b'9000-byte data gets trunca'...",
                "x": "&lt;__main__.Foo instance at 0x10057e128&gt;",
                "y": "[1, {2: \"foo\"}]",
            }
...
</pre>


This lets powerful open-source exception servers, e.g.

* [exception-server](https://github.com/andrewschaaf/exception-server)

and JavaScript widgets, e.g.

* exception-server's ExceptionWidget

focus on including awesome features, rather than a batallion of parsers.

## Integration Overview

### Python
<pre>
import common_exception
...
ce = common_exception.fromExceptionText(text)
...
except Exception:
    ce = common_exception.fromCurrentException()
</pre>

* Note: incomplete implementation not yet posted.

### Ruby

TODO

### JavaScript (NodeJS)
<pre>
var common_exception = require('common_exception');
...
var ce = common_exception.fromBrowserException(e);
...
catch(e) {
    var ce = common_exception.fromNodeException(e);
</pre>

### JavaScript (Browser)
{'fraction_non_alphanumeric': 0.15997968511934993, 'fraction_numerical': 0.014982224479431183, 'mean_word_length': 2.277038269550749, 'pattern_counts': {'":': 38, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '3461814', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1147, 'n_words': 311}