Last active
December 10, 2021 08:48
-
-
Save max-arshinov/78561fd73e59a9d17ec7563f55de6b40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>GistRun</title> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
<script src="script.js"></script> | |
<div id="text1"></div> | |
<div id="text2"></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Failure = class { | |
constructor(message){ | |
this.message = message; | |
} | |
} | |
let Exception = class { | |
constructor(message){ | |
this.message = message; | |
} | |
} | |
function getErrorResponse(e){ | |
console.log(e) | |
if(e instanceof Failure){ | |
// тут еще разное логирование | |
return { | |
message: e.message, | |
errorCode: 422 // в grapqhl будет другой | |
}; | |
}else{ | |
// тут еще разное логирование | |
return { | |
message: 'Ой, что-то пошло не так, наши доблестные инженеры уже все чинят', | |
errorCode: 500 // в grapqhl будет другой | |
}; | |
} | |
} | |
var response1 = ''; | |
var response2 = ''; | |
try { | |
throw new Failure('User friendly message here'); | |
}catch(e){ | |
response1 = getErrorResponse(e); | |
} | |
console.log(response1) | |
try { | |
throw new Exception('User friendly message here'); | |
}catch(e){ | |
response2 = getErrorResponse(e); | |
} | |
console.log(response2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* todo: add styles */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment