sourceError.html 7.3 KB
Newer Older
1
<!-- can not use doctype -->
2
<!--
Thomas Mueller's avatar
Thomas Mueller committed
3
Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License, Version 1.0,
4 5
and under the Eclipse Public License, Version 1.0
(http://h2database.com/html/license.html).
6 7
Initial Developer: H2 Group
-->
8 9 10 11
<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Online Error Analyzer</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<style type="text/css">
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;
}
28
input {
29
    vertical-align: middle;
30
}
31 32 33 34 35
</style>

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

36
function get(id) {
37
    return document.getElementById(id);
38 39
}

40 41 42
var lastError = '';
var hasData = false;
var errorCode = '0';
43
var build = 100;
44

45
function goDetails(code) {
46 47 48 49 50
    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');
51
    get('more').src = 'http://h2database.com/javadoc/org/h2/constant/ErrorCode.html#c' + code;
52 53
}

54
function go(file, line) {
55
    var url;
56
    if (get('rawSource').checked == true) {
57 58 59 60 61 62
        url = "source.html?file=";
        url += file;
        url += "&line=";
        url += line;
        url += "&build=";
        url += build;
63 64 65
    } else {
        var tag = 'trunk/h2';
        if (build == 64) {
66
            tag = 'tags/version-1.0.' + build;
67 68
        } else if (build >= 120) {
            tag = 'tags/version-1.2.' + build + '/h2';
69 70
        } else if (build >= 100) {
            tag = 'tags/version-1.1.' + build + '/h2';
71
        } else if (build >= 63) {
72 73 74 75 76 77 78 79 80
            tag = 'tags/version-1.0.' + build + '/h2';
        }
        url = 'http://code.google.com/p/h2database/source/browse/';
        url += tag;
        url += '/src/main/';
        url += file;
        url += '#';
        url += line;
    }
81 82
    get('file').innerHTML = file;
    get('code').src = url;
83 84 85
}

function convert() {
86
    try {
87
        var s = get('error').value;
88 89 90 91 92 93 94 95
        if(lastError == s) {
            return;
        }
        lastError = s;
        var result = '';
        hasData = false;
        var idx = s.lastIndexOf("[");
        if (idx >= 0) {
96
            get('message').innerHTML = s.substring(0, idx);
97 98 99 100
            var end = s.indexOf("]", idx);
            errorCode = s.substring(idx + 1, end);
            hasData = true;
            idx = errorCode.indexOf("-");
101
            build = parseInt(errorCode.substring(idx + 1));
102
            get('version').innerHTML = (build < 100 ? '1.0.' : (build < 120 ? '1.1.' : '1.2.')) + build;
103 104 105 106
            errorCode = errorCode.substring(0, idx);
            while (errorCode.length > 1 && errorCode.charAt(0) == '0') {
                errorCode = errorCode.substring(1);
            }
107
            get('errorCode').innerHTML = errorCode;
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
            goDetails(errorCode);
            s = s.substring(end + 1);
        }
        idx = 0;
        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;
142
            result += "<" + "/a>";
143 144 145 146 147
            hasData = true;
            idx = end + 1;
        }
        result = result.replace(/[\n\r]+/g, "<br/>");
        result = result.replace(/ at /g, "");
148
        get('links').innerHTML = result;
149
        select('input');
150
    } catch(e) {
151 152
        hasData = false;
        alert('Can not parse the stack trace: ' + e);
153 154 155 156 157
    }

}

function select(id) {
158 159 160 161 162 163 164 165
    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 = '';
166 167 168 169
    if(id=='details') {
        goDetails(errorCode);
    }
    sizeTextArea();
170 171 172 173
}

function sizeTextArea() {
    var height=document.body.clientHeight;
174
    var error = get('error');
175
    error.style.height = (height - error.offsetTop - 25) + 'px';
176
    var more = get('more');
177
    more.style.height = (height - more.offsetTop - 25) + 'px';
178 179
    var code = get('code');
    code.style.height = (height - get('sourceTable').offsetTop - code.offsetTop - 30) + 'px';
180 181 182 183 184
}

//-->
</script>

185 186 187 188
</head>
<body style="margin:20px" onresize="sizeTextArea();" onload="sizeTextArea();" >

<h1>Online Error Analyzer</h1>
189
<b><a href="../html/main.html">Home</a></b><br />
190
<h2>
Thomas Mueller's avatar
Thomas Mueller committed
191 192 193
    <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>
194 195
</h2>
<hr/>
Thomas Mueller's avatar
Thomas Mueller committed
196
<div id = "input">
197
    <p>Fill in the error message and stack trace and click on 'Details' or 'Source Code': </p>
Thomas Mueller's avatar
Thomas Mueller committed
198
    <textarea id = "error" cols="100" style="width: 100%; overflow: auto;" rows="20"
199 200 201 202 203 204 205 206
        onChange="convert()"
        onSelect="convert()"
        onKeyUp="convert()"
        onKeyPress="convert()"
        onFocus="convert()"
        onBlur="convert()"
    >
    </textarea>
207
</div>
Thomas Mueller's avatar
Thomas Mueller committed
208 209 210
<div id = "details">
    <p><b>Error Code: </b><span id = "errorCode"></span></p>
    <p><b>Product Version: </b><span id = "version"></span></p>
211
    <p><b>Message: </b></p>
Thomas Mueller's avatar
Thomas Mueller committed
212
    <p id = "message"></p>
213
    <p><b>More Information:</b></p>
Thomas Mueller's avatar
Thomas Mueller committed
214
    <iframe id = "more" frameborder="0" marginwidth="0" marginheight="0" width="100%" height="100px" src="">
215
    </iframe>
216
</div>
Thomas Mueller's avatar
Thomas Mueller committed
217 218
<div id = "source">
    <table id = "sourceTable" style="border:0px" width="100%"><tr>
219 220
    <td style="border:0px" width="30px">
        <p><b>Stack Trace: </b></p>
Thomas Mueller's avatar
Thomas Mueller committed
221
        <p id = "links"></p>
222
    </td><td style="border:0px" width="90%">
Thomas Mueller's avatar
Thomas Mueller committed
223 224 225
        <p><b>Source File: </b><span id = "file"></span><br />
        Raw file <input type="checkbox" id = "rawSource" /> (fast; only Firefox)</p>
        <iframe id = "code" frameborder="0" marginwidth="0" marginheight="0" width="100%" height="100px" src="">
226 227 228
        </iframe>
    </td>
    </tr></table>
229 230 231 232 233 234
</div>
<script type="text/javascript">
//<!--
select('input');
//-->
</script>
235 236
<!-- analytics -->
</body></html>