Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
494b7b7d
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
494b7b7d
编写于
6月 16, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bring "hidden" code out in the open
上级
748ceac1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
52 deletion
+71
-52
src/vs/base/common/errors.ts
src/vs/base/common/errors.ts
+52
-1
src/vs/base/common/winjs.base.d.ts
src/vs/base/common/winjs.base.d.ts
+17
-0
src/vs/base/common/winjs.base.js
src/vs/base/common/winjs.base.js
+2
-51
未找到文件。
src/vs/base/common/errors.ts
浏览文件 @
494b7b7d
...
...
@@ -8,7 +8,58 @@ import platform = require('vs/base/common/platform');
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
,
IPromiseError
,
IPromiseErrorDetail
}
from
'
vs/base/common/winjs.base
'
;
// ------ BEGIN Hook up error listeners to winjs promises
let
outstandingPromiseErrors
:
{
[
id
:
string
]:
IPromiseErrorDetail
;
}
=
{};
function
promiseErrorHandler
(
e
:
IPromiseError
):
void
{
//
// e.detail looks like: { exception, error, promise, handler, id, parent }
//
var
details
=
e
.
detail
;
var
id
=
details
.
id
;
// If the error has a parent promise then this is not the origination of the
// error so we check if it has a handler, and if so we mark that the error
// was handled by removing it from outstandingPromiseErrors
//
if
(
details
.
parent
)
{
if
(
details
.
handler
&&
outstandingPromiseErrors
)
{
delete
outstandingPromiseErrors
[
id
];
}
return
;
}
// Indicate that this error was originated and needs to be handled
outstandingPromiseErrors
[
id
]
=
details
;
// The first time the queue fills up this iteration, schedule a timeout to
// check if any errors are still unhandled.
if
(
Object
.
keys
(
outstandingPromiseErrors
).
length
===
1
)
{
setTimeout
(
function
()
{
var
errors
=
outstandingPromiseErrors
;
outstandingPromiseErrors
=
{};
Object
.
keys
(
errors
).
forEach
(
function
(
errorId
)
{
var
error
=
errors
[
errorId
];
if
(
error
.
exception
)
{
onUnexpectedError
(
error
.
exception
);
}
else
if
(
error
.
error
)
{
onUnexpectedError
(
error
.
error
);
}
console
.
log
(
'
WARNING: Promise with no error callback:
'
+
error
.
id
);
console
.
log
(
error
);
if
(
error
.
exception
)
{
console
.
log
(
error
.
exception
.
stack
);
}
});
},
0
);
}
}
TPromise
.
addEventListener
(
'
error
'
,
promiseErrorHandler
);
// ------ END Hook up error listeners to winjs promises
export
interface
ErrorListenerCallback
{
(
error
:
any
):
void
;
...
...
src/vs/base/common/winjs.base.d.ts
浏览文件 @
494b7b7d
...
...
@@ -55,6 +55,18 @@ export interface TProgressCallback<T> {
(
progress
:
T
):
void
;
}
interface
IPromiseErrorDetail
{
parent
:
TPromise
<
any
>
;
error
:
any
;
id
:
number
;
handler
:
Function
;
exception
:
Error
;
}
interface
IPromiseError
{
detail
:
IPromiseErrorDetail
;
}
/**
* A Promise implementation that supports progress and cancelation.
*/
...
...
@@ -95,6 +107,11 @@ export declare class TPromise<V> {
public
static
wrap
<
ValueType
>
(
value
:
ValueType
):
TPromise
<
ValueType
>
;
public
static
wrapError
<
ValueType
>
(
error
:
any
):
TPromise
<
ValueType
>
;
/**
* @internal
*/
public
static
addEventListener
(
event
:
'
error
'
,
promiseErrorHandler
:
(
e
:
IPromiseError
)
=>
void
);
}
// --- Generic promise with generic progress value
...
...
src/vs/base/common/winjs.base.js
浏览文件 @
494b7b7d
...
...
@@ -3,60 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
define
([
'
./winjs.base.raw
'
,
'
vs/base/common/errors
'
],
function
(
winjs
,
__Errors__
)
{
define
([
'
./winjs.base.raw
'
],
function
(
winjs
)
{
'
use strict
'
;
var
outstandingPromiseErrors
=
{};
function
promiseErrorHandler
(
e
)
{
//
// e.detail looks like: { exception, error, promise, handler, id, parent }
//
var
details
=
e
.
detail
;
var
id
=
details
.
id
;
// If the error has a parent promise then this is not the origination of the
// error so we check if it has a handler, and if so we mark that the error
// was handled by removing it from outstandingPromiseErrors
//
if
(
details
.
parent
)
{
if
(
details
.
handler
&&
outstandingPromiseErrors
)
{
delete
outstandingPromiseErrors
[
id
];
}
return
;
}
// Indicate that this error was originated and needs to be handled
outstandingPromiseErrors
[
id
]
=
details
;
// The first time the queue fills up this iteration, schedule a timeout to
// check if any errors are still unhandled.
if
(
Object
.
keys
(
outstandingPromiseErrors
).
length
===
1
)
{
setTimeout
(
function
()
{
var
errors
=
outstandingPromiseErrors
;
outstandingPromiseErrors
=
{};
Object
.
keys
(
errors
).
forEach
(
function
(
errorId
)
{
var
error
=
errors
[
errorId
];
if
(
error
.
exception
)
{
__Errors__
.
onUnexpectedError
(
error
.
exception
);
}
else
if
(
error
.
error
)
{
__Errors__
.
onUnexpectedError
(
error
.
error
);
}
console
.
log
(
"
WARNING: Promise with no error callback:
"
+
error
.
id
);
console
.
log
(
error
);
if
(
error
.
exception
)
{
console
.
log
(
error
.
exception
.
stack
);
}
});
},
0
);
}
}
winjs
.
Promise
.
addEventListener
(
"
error
"
,
promiseErrorHandler
);
return
{
Promise
:
winjs
.
Promise
,
TPromise
:
winjs
.
Promise
,
PPromise
:
winjs
.
Promise
};
});
\ No newline at end of file
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录