mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-26 21:23:53 -06:00
Refactor to make failure messages more consistent
This commit is contained in:
parent
925582d034
commit
42dc4155ce
@ -623,8 +623,7 @@ namespace ts.server {
|
||||
|
||||
positionToLineOffset(position: number): protocol.Location {
|
||||
const location = this.textStorage.positionToLineOffset(position);
|
||||
Debug.assert(typeof location.line === "number" && location.line > 0, `Expected line ${location.line} to be greater than 0.`);
|
||||
Debug.assert(typeof location.offset === "number" && location.offset > 0, `Expected offset ${location.offset} to be greater than 0.`);
|
||||
failIfInvalidLocation(location);
|
||||
return location;
|
||||
}
|
||||
|
||||
@ -645,4 +644,13 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
function failIfInvalidLocation(location: protocol.Location) {
|
||||
Debug.assert(typeof location.line === "number", `Expected line ${location.line} to be a number.`);
|
||||
Debug.assert(typeof location.offset === "number", `Expected offset ${location.offset} to be a number.`);
|
||||
|
||||
Debug.assert(location.line > 0, `Expected line to be non-${location.line === 0 ? "zero" : "negative"}`);
|
||||
Debug.assert(location.offset > 0, `Expected offset to be non-${location.offset === 0 ? "zero" : "negative"}`);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user