本文整理汇总了TypeScript中vs/base/common/errors.onUnexpectedError函数的典型用法代码示例。如果您正苦于以下问题:TypeScript onUnexpectedError函数的具体用法?TypeScript onUnexpectedError怎么用?TypeScript onUnexpectedError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了onUnexpectedError函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _safeCallOnDomNodeTop
private _safeCallOnDomNodeTop(zone: IViewZone, top: number): void {
if (typeof zone.onDomNodeTop === 'function') {
try {
zone.onDomNodeTop(top);
} catch (e) {
onUnexpectedError(e);
}
}
}
示例2: _safeCallOnComputedHeight
private _safeCallOnComputedHeight(zone: IViewZone, height: number): void {
if (typeof zone.onComputedHeight === 'function') {
try {
zone.onComputedHeight(height);
} catch (e) {
onUnexpectedError(e);
}
}
}
示例3: _getLanguageDefinedShouldAutoClose
private static _getLanguageDefinedShouldAutoClose(languageIdentifier: LanguageIdentifier): (ch: string) => boolean {
try {
const autoCloseBeforeSet = LanguageConfigurationRegistry.getAutoCloseBeforeSet(languageIdentifier.id);
return c => autoCloseBeforeSet.indexOf(c) !== -1;
} catch (e) {
onUnexpectedError(e);
return autoCloseNever;
}
}
示例4: Error
$onUnexpectedError(err: any | SerializedError, extensionId: string | undefined): void {
if (err.$isError) {
const { name, message, stack } = err;
err = new Error();
err.message = extensionId ? `[${extensionId}] ${message}` : message;
err.name = name;
err.stack = stack;
}
onUnexpectedError(err);
}
示例5: Error
$onUnexpectedError(err: any | SerializedError): void {
if (err && err.$isError) {
const { name, message, stack } = err;
err = new Error();
err.message = message;
err.name = name;
err.stack = stack;
}
onUnexpectedError(err);
}
示例6: _isAutoClosingOpenCharType
private static _isAutoClosingOpenCharType(config: CursorConfiguration, model: ITextModel, selections: Selection[], ch: string): boolean {
if (!config.autoClosingBrackets || !config.autoClosingPairsOpen.hasOwnProperty(ch)) {
return false;
}
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
if (!selection.isEmpty()) {
return false;
}
const position = selection.getPosition();
const lineText = model.getLineContent(position.lineNumber);
// Do not auto-close ' or " after a word character
if ((ch === '\'' || ch === '"') && position.column > 1) {
const wordSeparators = getMapForWordSeparators(config.wordSeparators);
const characterBeforeCode = lineText.charCodeAt(position.column - 2);
const characterBeforeType = wordSeparators.get(characterBeforeCode);
if (characterBeforeType === WordCharacterClass.Regular) {
return false;
}
}
// Only consider auto closing the pair if a space follows or if another autoclosed pair follows
const characterAfter = lineText.charAt(position.column - 1);
if (characterAfter) {
let isBeforeCloseBrace = TypeOperations._isBeforeClosingBrace(config, ch, characterAfter);
if (!isBeforeCloseBrace && !/\s/.test(characterAfter)) {
return false;
}
}
if (!model.isCheapToTokenize(position.lineNumber)) {
// Do not force tokenization
return false;
}
model.forceTokenization(position.lineNumber);
const lineTokens = model.getLineTokens(position.lineNumber);
let shouldAutoClosePair = false;
try {
shouldAutoClosePair = LanguageConfigurationRegistry.shouldAutoClosePair(ch, lineTokens, position.column);
} catch (e) {
onUnexpectedError(e);
}
if (!shouldAutoClosePair) {
return false;
}
}
return true;
}
示例7: _typeInterceptorAutoClosingOpenChar
private static _typeInterceptorAutoClosingOpenChar(config: CursorConfiguration, model: ITokenizedModel, cursor: SingleCursorState, ch: string): EditOperationResult {
if (!config.autoClosingBrackets) {
return null;
}
let selection = cursor.selection;
if (!selection.isEmpty() || !config.autoClosingPairsOpen.hasOwnProperty(ch)) {
return null;
}
let position = cursor.position;
let lineText = model.getLineContent(position.lineNumber);
let beforeCharacter = lineText.charAt(position.column - 1);
// Only consider auto closing the pair if a space follows or if another autoclosed pair follows
if (beforeCharacter) {
let thisBraceIsSymmetric = (config.autoClosingPairsOpen[ch] === ch);
let isBeforeCloseBrace = false;
for (let otherCloseBrace in config.autoClosingPairsClose) {
let otherBraceIsSymmetric = (config.autoClosingPairsOpen[otherCloseBrace] === otherCloseBrace);
if (!thisBraceIsSymmetric && otherBraceIsSymmetric) {
continue;
}
if (beforeCharacter === otherCloseBrace) {
isBeforeCloseBrace = true;
break;
}
}
if (!isBeforeCloseBrace && !/\s/.test(beforeCharacter)) {
return null;
}
}
let lineTokens = model.getLineTokens(position.lineNumber, false);
let shouldAutoClosePair = false;
try {
shouldAutoClosePair = LanguageConfigurationRegistry.shouldAutoClosePair(ch, lineTokens, position.column);
} catch (e) {
onUnexpectedError(e);
}
if (!shouldAutoClosePair) {
return null;
}
let closeCharacter = config.autoClosingPairsOpen[ch];
return new EditOperationResult(new ReplaceCommandWithOffsetCursorState(selection, ch + closeCharacter, 0, -closeCharacter.length), {
shouldPushStackElementBefore: true,
shouldPushStackElementAfter: false
});
}
示例8: _handle
private _handle(): void {
if (this._handler === null || this._users === null || this._delta === null) {
return;
}
try {
this._handler(this._users, this._delta);
} catch (err) {
onUnexpectedError(err);
}
}
示例9: _typeInterceptorElectricChar
private static _typeInterceptorElectricChar(config: CursorConfiguration, model: ITokenizedModel, cursor: SingleCursorState, ch: string): EditOperationResult {
if (!config.electricChars.hasOwnProperty(ch)) {
return null;
}
let position = cursor.position;
let lineTokens = model.getLineTokens(position.lineNumber, false);
let electricAction: IElectricAction;
try {
electricAction = LanguageConfigurationRegistry.onElectricCharacter(ch, lineTokens, position.column);
} catch (e) {
onUnexpectedError(e);
}
if (!electricAction) {
return null;
}
if (electricAction.appendText) {
return new EditOperationResult(new ReplaceCommandWithOffsetCursorState(cursor.selection, ch + electricAction.appendText, 0, -electricAction.appendText.length), {
shouldPushStackElementBefore: false,
shouldPushStackElementAfter: true
});
}
if (electricAction.matchOpenBracket) {
let match = model.findMatchingBracketUp(electricAction.matchOpenBracket, {
lineNumber: position.lineNumber,
column: position.column
});
if (match) {
let matchLine = model.getLineContent(match.startLineNumber);
let matchLineIndentation = strings.getLeadingWhitespace(matchLine);
let newIndentation = config.normalizeIndentation(matchLineIndentation);
let lineText = model.getLineContent(position.lineNumber);
let lineFirstNonBlankColumn = model.getLineFirstNonWhitespaceColumn(position.lineNumber) || position.column;
let prefix = lineText.substring(lineFirstNonBlankColumn - 1, position.column - 1);
let typeText = newIndentation + prefix + ch;
let typeSelection = new Range(position.lineNumber, 1, position.lineNumber, position.column);
return new EditOperationResult(new ReplaceCommand(typeSelection, typeText), {
shouldPushStackElementBefore: false,
shouldPushStackElementAfter: true
});
}
}
return null;
}
示例10: catch
TPromise.timeout(50).done(() => {
// Some actions are enabled only when editor has focus
this.editor.focus();
try {
let promise = this.action.run() || TPromise.as(null);
promise.done(null, onUnexpectedError);
} catch (error) {
onUnexpectedError(error);
}
}, onUnexpectedError);