async错误处理

news/2024/7/9 23:47:53 标签: vue, javascript
javascript">async function helloAsync() {
    await new Promise(function (resolve, reject) {
        throw new Error('错误');
    });
}
helloAsync().then(v => console.log(v))
.catch(e => console.log(e.message));

上面是js文件,下面是html文件
html文件console中啥也没有,也可能是我不会用

javascript"><!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
	</head>
	<body>
		
	
	    
		<script>
		  async function helloAsync() {
    await new Promise(function (resolve, reject) {
        throw new Error('错误');
    });
}
helloAsync().then(v => console.log(v))
.catch(e => console.log(e.message));
		
		</script>
	</body>
</html>

http://www.niftyadmin.cn/n/957360.html

相关文章

【星际争霸2中的强化学习-1】使用 PySC2 构建虫族机器人

中文网站上关于星际争霸2中AI模型的训练资料非常少&#xff0c;这里找到一篇比较好的pysc2使用的文章&#xff0c;翻译一下&#xff0c;方便阅读。 代码&#xff1a;GitHub - skjb/pysc2-tutorial: Tutorials for building a PySC2 botTutorials for building a PySC2 bot. Co…

防止async出错的方法

async function helloAsync() {try{await new Promise(function (resolve, reject) {throw new Error(错误);}); } catch(e) { } return await(hello); } helloAsync().then(v > console.log(v)) //catch(e > console.log(e.message));以上是js文件&#xff0c;以下是htm…

pygame将当前画面输出到变量

from PIL import Image import pygame import numpy as nppygame.display.update() # 更新画面 pil_string_image pygame.image.tostring(screen, "RGB", False) # 将当前图像输出为字符变量 pli_image Image.frombytes(RGB, screen.get_size(), pil_string_image…

错误的这个在html的console里也是有的,刚才是看花眼了吗

<!DOCTYPE html> <html><head><meta charset"UTF-8"></head><body><script>async function helloAsync() {await new Promise(function (resolve, reject) {throw new Error(错误);}); } helloAsync().then(v > consol…

强化学习调参实践

1、如果出现神经网络输出数值很大&#xff0c;而且过快收敛问题&#xff0c;如下 那么有可能是state没有除255。 重新试试 2、ValueError: The parameter probs has invalid values或模型输出nan 模型输入的数据可能为&#xff08;1&#xff0c;N&#xff0c;84&#xff0c;8…

promise的用法,为什么不是运行出3呢?ex是什么意思?

const promise new Promise(function(resolve, reject) {setTimeout(function() {try{let c 6 / 2 ;resolve(c);} catch(ex) {reject(ex);}}, 1000) })不知道怎么debug得出3来。 为啥是underfined&#xff1f; <!DOCTYPE html> <html><head><meta cha…

ray安装踩坑记录

Ray是个复杂的库&#xff0c;安装非常依赖各个包的版本&#xff0c;只要按照时间顺序&#xff0c;逐个安装即可。 坑一&#xff1a; 当前ray的最新版本为1.8.0&#xff0c;对应的cloudpickle为2.0.0&#xff0c;无法执行 ray.init() 报错为typeerror&#xff1a;cant pickl…

【Pytorch异常笔记】Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.

异常描述 OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized. OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or c…