Skip to content

Commit b926035

Browse files
committed
Add better error message
1 parent 15ddcf3 commit b926035

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/document.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ end
6363
"""
6464
get_offset(doc, line, char)
6565
66-
Returns the byte offset position corresponding to a line/character position.
66+
Returns the byte offset position corresponding to a line/character position.
6767
This takes 0 based line/char inputs. Corresponding functions are available for
6868
Position and Range arguments, the latter returning a UnitRange{Int}.
6969
"""
@@ -101,10 +101,10 @@ function get_offset2(doc::Document, line::Integer, character::Integer)
101101
text = get_text(doc)
102102

103103
if line >= length(line_offsets)
104-
error("Invalid arguments.")
104+
throw(LSOffsetError("get_offset2 crashed. More diagnostics:\nline=$line\nline_offsets='$line_offsets'"))
105105
return nextind(text, lastindex(text))
106106
elseif line < 0
107-
error("Invalid arguments.")
107+
throw(LSOffsetError("get_offset2 crashed. More diagnostics:\nline=$line\nline_offsets='$line_offsets'"))
108108
end
109109

110110
line_offset = line_offsets[line + 1]
@@ -153,9 +153,9 @@ end
153153

154154
"""
155155
get_line_offsets(doc::Document)
156-
157-
Updates the doc._line_offsets field, an n length Array each entry of which
158-
gives the byte offset position of the start of each line. This always starts
156+
157+
Updates the doc._line_offsets field, an n length Array each entry of which
158+
gives the byte offset position of the start of each line. This always starts
159159
with 0 for the first line (even if empty).
160160
"""
161161
function get_line_offsets(doc::Document, force=false)

0 commit comments

Comments
 (0)