我不确定完整的上下文是什么,但我认为你可以这样做:
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
try {
// ...
} catch (e) {
popupAjaxError(e);
}
// 或者
ajax("...") // 某个函数
.then(() => {
// ...
})
.catch(popupAjaxError);