sourceError.html 7.6 KB
Newer Older
1
<!-- can not use doctype -->
2
<!--
3
Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0, Version 1.0,
4
and under the Eclipse Public License, Version 1.0
5 6
Initial Developer: H2 Group
-->
7 8
<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
Thomas Mueller's avatar
Thomas Mueller committed
9
<meta name="viewport" content="width=device-width, initial-scale=1" />
10
<title>Error Analyzer</title>
11
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
12
<style type="text/css">
13 14
body {
    max-width: none;
Thomas Mueller's avatar
Thomas Mueller committed
15
    width: inherit;
16
}
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
a {
    text-decoration: underline;
    font-weight: normal;
    color: #0000ff;
}
a.selected {
    text-decoration: none;
    font-weight: bold;
    color: #000000;
}
a.disabled {
    text-decoration: none;
    font-weight: normal;
    color: lightGray;
}
32
input {
33
    vertical-align: middle;
34
}
35 36 37 38 39
</style>

<script type="text/javascript">
//<!--

Thomas Mueller's avatar
Thomas Mueller committed
40 41
function getVersion(build) {
    if (build == 64) {
42
        return '1.0/version-1.0.' + build;
43 44
    } else if (build >= 177) {
        return '1.4.' + build;
Thomas Mueller's avatar
Thomas Mueller committed
45
    } else if (build >= 146 && build != 147) {
Thomas Mueller's avatar
Thomas Mueller committed
46
        return '1.3/version-1.3.' + build;
Thomas Mueller's avatar
Thomas Mueller committed
47
    } else if (build >= 120) {
48
        return '1.2/version-1.2.' + build;
Thomas Mueller's avatar
Thomas Mueller committed
49
    } else if (build >= 100) {
50
        return '1.1/version-1.1.' + build;
Thomas Mueller's avatar
Thomas Mueller committed
51 52 53 54
    }
    return '1.0.' + build;
}

55
function get(id) {
56
    return document.getElementById(id);
57 58
}

59 60 61
var lastError = '';
var hasData = false;
var errorCode = '0';
62
var build = 100;
63

64
function goDetails(code) {
65 66 67 68 69
    code = code.replace('21S', '210');
    code = code.replace('42S', '421');
    code = code.replace('HY', '50');
    code = code.replace('C', '1');
    code = code.replace('T', '2');
70
    get('more').src = 'http://h2database.com/javadoc/org/h2/constant/ErrorCode.html#c' + code;
71 72
}

73
function go(file, line) {
74
    var url;
75
    if (get('rawSource').checked == true) {
76 77 78 79 80 81
        url = "source.html?file=";
        url += file;
        url += "&line=";
        url += line;
        url += "&build=";
        url += build;
82
        get('file').innerHTML = file;
83
        get('code').src = url;
84
    } else {
85
        url = 'https://github.com/h2database/h2database/tree/'
86
        if (build && build > 0) {
87
            url += 'version-' + getVersion(build) + '/h2';
88
        } else {
89
            var tag = 'master/h2';
90
        }
91 92 93 94
        url += '/src/main/';
        url += file;
        url += '#';
        url += line;
95 96
        // X-Frame-Options is now 'SAMEORIGIN'
        window.open(url);
97
    }
98 99 100
}

function convert() {
101
    try {
102
        var s = get('error').value;
103 104 105 106 107 108 109 110
        if(lastError == s) {
            return;
        }
        lastError = s;
        var result = '';
        hasData = false;
        var idx = s.lastIndexOf("[");
        if (idx >= 0) {
111
            get('message').innerHTML = s.substring(0, idx);
112 113 114 115
            var end = s.indexOf("]", idx);
            errorCode = s.substring(idx + 1, end);
            hasData = true;
            idx = errorCode.indexOf("-");
116
            build = parseInt(errorCode.substring(idx + 1));
Thomas Mueller's avatar
Thomas Mueller committed
117
            get('version').innerHTML = getVersion(build);
118 119 120 121
            errorCode = errorCode.substring(0, idx);
            while (errorCode.length > 1 && errorCode.charAt(0) == '0') {
                errorCode = errorCode.substring(1);
            }
122
            get('errorCode').innerHTML = errorCode;
123 124 125
            goDetails(errorCode);
        }
        idx = 0;
126 127
        s = s.replace(/\t/g, " ");
        s = s.replace(/ +/g, " ");
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
        while (true) {
            var start = s.indexOf("at org.h2.", idx);
            if (start < 0) {
                result += s.substring(idx);
                break;
            }
            start += 3; // skip 'at '
            if (idx > 0) {
                result += s.substring(idx, start);
            }
            var end = s.indexOf(')', start);
            if (end < 0) {
                result += s.substring(idx);
                break;
            }
            var element = s.substring(start, end + 1);
            var open = element.lastIndexOf('(');
            var dotMethod = element.lastIndexOf('.', open - 1);
            var dotClass = element.lastIndexOf('.', dotMethod - 1);
            var packageName = element.substring(0, dotClass);
            var colon = element.lastIndexOf(':');
            var file = element.substring(open + 1, colon);
            var lineNumber = element.substring(colon + 1, element.length - 1);
            var fullFileName = packageName.replace(/\./g, '/') + "/" + file;
            result += "<a href='javascript:go(\"";
            result += fullFileName;
            result += "\",";
            result += lineNumber;
            result += ")'>";
            result += element;
158
            result += "<" + "/a>";
159 160 161 162 163
            hasData = true;
            idx = end + 1;
        }
        result = result.replace(/[\n\r]+/g, "<br/>");
        result = result.replace(/ at /g, "");
164
        get('links').innerHTML = result;
165
        select('input');
166
    } catch(e) {
167 168
        hasData = false;
        alert('Can not parse the stack trace: ' + e);
169 170 171 172 173
    }

}

function select(id) {
174 175 176 177 178 179 180 181
    get('input').style.display = 'none';
    get('details').style.display = 'none';
    get('source').style.display = 'none';
    get('inputTab').className = '';
    get('detailsTab').className = hasData ? '' : 'disabled';
    get('sourceTab').className = hasData ? '' : 'disabled';
    get(id + 'Tab').className = 'selected';
    get(id).style.display = '';
182 183 184 185
    if(id=='details') {
        goDetails(errorCode);
    }
    sizeTextArea();
186 187 188 189
}

function sizeTextArea() {
    var height=document.body.clientHeight;
190
    var error = get('error');
191
    error.style.height = (height - error.offsetTop - 25) + 'px';
192
    var more = get('more');
193
    more.style.height = (height - more.offsetTop - 25) + 'px';
194 195
    var code = get('code');
    code.style.height = (height - get('sourceTable').offsetTop - code.offsetTop - 30) + 'px';
196 197 198 199 200
}

//-->
</script>

201 202 203
</head>
<body style="margin:20px" onresize="sizeTextArea();" onload="sizeTextArea();" >

204
<h1>Error Analyzer</h1>
205
<b><a href="../html/main.html">Home</a></b><br />
206
<h2>
Thomas Mueller's avatar
Thomas Mueller committed
207 208 209
    <a href="javascript:select('input')" id = "inputTab">Input</a>&nbsp;
    <a href="javascript:select('details')" id = "detailsTab">Details</a>&nbsp;
    <a href="javascript:select('source')" id = "sourceTab">Source Code</a>
210 211
</h2>
<hr/>
Thomas Mueller's avatar
Thomas Mueller committed
212
<div id = "input">
213
    <p>Paste the error message and stack trace below and click on 'Details' or 'Source Code': </p>
Thomas Mueller's avatar
Thomas Mueller committed
214
    <textarea id = "error" cols="100" style="width: 100%; overflow: auto;" rows="20"
215 216 217 218 219 220 221 222
        onChange="convert()"
        onSelect="convert()"
        onKeyUp="convert()"
        onKeyPress="convert()"
        onFocus="convert()"
        onBlur="convert()"
    >
    </textarea>
223
</div>
Thomas Mueller's avatar
Thomas Mueller committed
224 225 226
<div id = "details">
    <p><b>Error Code: </b><span id = "errorCode"></span></p>
    <p><b>Product Version: </b><span id = "version"></span></p>
227
    <p><b>Message: </b></p>
Thomas Mueller's avatar
Thomas Mueller committed
228
    <p id = "message"></p>
229
    <p><b>More Information:</b></p>
Thomas Mueller's avatar
Thomas Mueller committed
230
    <iframe id = "more" frameborder="0" marginwidth="0" marginheight="0" width="100%" height="100px" src="">
231
    </iframe>
232
</div>
Thomas Mueller's avatar
Thomas Mueller committed
233 234
<div id = "source">
    <table id = "sourceTable" style="border:0px" width="100%"><tr>
235 236
    <td style="border:0px" width="30px">
        <p><b>Stack Trace: </b></p>
Thomas Mueller's avatar
Thomas Mueller committed
237
        <p id = "links"></p>
238
    </td><td style="border:0px" width="90%">
Thomas Mueller's avatar
Thomas Mueller committed
239
        <p><b>Source File: </b><span id = "file"></span><br />
240 241
        Inline <input type="checkbox" id = "rawSource" checked="checked" /></p>
        <iframe id = "code" frameborder="0" marginwidth="0" marginheight="0" width="4000px" height="100px" src="">
242 243 244
        </iframe>
    </td>
    </tr></table>
245 246 247 248 249 250
</div>
<script type="text/javascript">
//<!--
select('input');
//-->
</script>
251 252
<!-- analytics -->
</body></html>