this.checkError = ()=> {
const checkData = this.getCheckData();
for (let rule of this.rules) {
try {
rule(checkData);
}
catch (e) {
return e;
}
}
return null;
};
this.checkError = async ()=> {
const checkData = this.getCheckData();
for (let rule of this.rules) {
try {
await rule(checkData);
}
catch (e) {
return e;
}
}
return null;
};bluebird.js:1590 Unhandled rejection Error at http://localhost:8003/main.js?1d0a58ad9037ab77a837:46664:23 at Validator.checkError (http://localhost:8003/main.js?1d0a58ad9037ab77a837:161451:11) at Validator.updateCheckingState (http://localhost:8003/main.js?1d0a58ad9037ab77a837:161464:25) at http://localhost:8003/main.js?1d0a58ad9037ab77a837:161480:13 at Validator.validate (http://localhost:8003/main.js?1d0a58ad9037ab77a837:161479:12) at run (http://localhost:8003/vendors-node_modules_hot-loader_react-dom_server_browser_js-node_modules_actr-rail-scheme_lib-2dffcc.js?1d0a58ad9037ab77a837:147004:13) at runIfPresent (http://localhost:8003/vendors-node_modules_hot-loader_react-dom_server_browser_js-node_modules_actr-rail-scheme_lib-2dffcc.js?1d0a58ad9037ab77a837:147033:21) at onGlobalMessage (http://localhost:8003/vendors-node_modules_hot-loader_react-dom_server_browser_js-node_modules_actr-rail-scheme_lib-2dffcc.js?1d0a58ad9037ab77a837:147073:17)validateNotEmpty = val => {
try {
if (!val) {
throw new Error();
}
}
catch(e) {
throw e;
}
}
const validateNotEmpty = val => {
try {
if (!val) {
throw new Error();
}
}
catch(e) {
throw e;
}
}
class Oppa {
rules = [
validateNotEmpty
];
idisuda = true;
getCheckData() {
return this.idisuda;
}
constructor() {
this.checkError = ()=> {
const checkData = this.getCheckData();
for (let rule of this.rules) {
try {
rule(checkData);
}
catch (e) {
return e;
}
}
return null;
};
this.updateCheckingState = ()=> {
this.error = this.checkError();
this.cleared = false;
this.checked = true;
return this;
};
}
}
const nuka = new Oppa();
nuka.idisuda = true;
nuka.updateCheckingState()
console.log('getCheckData', nuka.idisuda,'isError', nuka.error instanceof Error)
nuka.updateCheckingState()
console.log('getCheckData', nuka.idisuda,'isError', nuka.error instanceof Error)
nuka.updateCheckingState()
console.log('getCheckData', nuka.idisuda,'isError', nuka.error instanceof Error)
nuka.idisuda = false;
nuka.updateCheckingState()
console.log('getCheckData', nuka.idisuda,'isError', nuka.error instanceof Error)
nuka.updateCheckingState()
console.log('getCheckData', nuka.idisuda,'isError', nuka.error instanceof Error)
nuka.updateCheckingState()
console.log('getCheckData', nuka.idisuda,'isError', nuka.error instanceof Error)Событие unhandledrejection происходит, когда Promise завершён с ошибкой, но на данную ошибку не установлен обработчик.
checkError().catch(console.error)this.checkError = ()=> {
return (new Promise((resolve, reject)=> {
const checkData = this.getCheckData();
for (let rule of this.rules) {
try {
rule(checkData);
}
catch (e) {
reject(e);
}
}
resolve(null);
}))
};
this.updateCheckingState = ()=> {
this.checkError()
.then( () => this.error = null )
.catch( e => this.error = e );
this.cleared = false;
this.checked = true;
return this;
};Unhandled rejection Error at http://localhost:8003/main.js?3aa0a28b8eef9439dfc4:46658:23 at http://localhost:8003/main.js?3aa0a28b8eef9439dfc4:161446:13 at Validator.checkError (http://localhost:8003/main.js?3aa0a28b8eef9439dfc4:161438:12) at Validator.updateCheckingState (http://localhost:8003/main.js?3aa0a28b8eef9439dfc4:161460:11) at http://localhost:8003/main.js?3aa0a28b8eef9439dfc4:161480:13From previous event: at Validator.validate (http://localhost:8003/main.js?3aa0a28b8eef9439dfc4:161479:12) at run (http://localhost:8003/vendors-node_modules_hot-loader_react-dom_server_browser_js-node_modules_actr-rail-scheme_lib-2dffcc.js?3aa0a28b8eef9439dfc4:147004:13) at runIfPresent (http://localhost:8003/vendors-node_modules_hot-loader_react-dom_server_browser_js-node_modules_actr-rail-scheme_lib-2dffcc.js?3aa0a28b8eef9439dfc4:147033:21) at onGlobalMessage (http://localhost:8003/vendors-node_modules_hot-loader_react-dom_server_browser_js-node_modules_actr-rail-scheme_lib-2dffcc.js?3aa0a28b8eef9439dfc4:147073:17)