本文整理汇总了TypeScript中@ionic/utils-stream.WritableStreamBuffer.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript WritableStreamBuffer.on方法的具体用法?TypeScript WritableStreamBuffer.on怎么用?TypeScript WritableStreamBuffer.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ionic/utils-stream.WritableStreamBuffer
的用法示例。
在下文中一共展示了WritableStreamBuffer.on方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: debug
.on('response', res => {
debug('response %d received for %s: (id: %s)', res.statusCode, resource.name, resource.imageId);
if (res.statusCode !== 200) {
const generalErrorMsg = !res.statusCode || res.statusCode >= 500
? 'the server may be experiencing difficulties right now--please try again later.'
: 'the server marked a source image as invalid for this resource.';
errorMarker = true;
const buf = new WritableStreamBuffer();
res.pipe(buf);
buf.on('finish', () => {
let serverMsg = buf.consume().toString();
try {
serverMsg = JSON.parse(serverMsg).Error;
} catch (e) {
serverMsg = formatResponseError(req, res.statusCode, serverMsg);
}
result.error = new Error(
`Error while generating ${strong(resource.name)}: ` +
`${generalErrorMsg}\n\n` +
`Server: "${serverMsg}"`
);
resolve(result);
});
}
})