Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tak jest źle!:
- ```
- function costam () {
- return new Promise((resolve, reject) => {
- reject(new Error('Abrakadabra hokus pokus!'))
- })
- }
- function costamRobiaceCostam () {
- return costam().then(() => {
- }).catch(err => err)
- }
- async function abecadlo () {
- try {
- await costamRobiaceCostam()
- }
- catch (err) {
- console.log('wysypao sie')
- }
- }
- abecadlo()
- ```
- a tak być powinno:
- ```
- function costam () {
- return new Promise((resolve, reject) => {
- reject(new Error('Abrakadabra hokus pokus!'))
- })
- }
- function costamRobiaceCostam () {
- return costam().then(() => {
- })
- // jeśli nic z errorem nie zamierzamy zrobić, kasujemy poniższą linijkę
- .catch(err => {throw err})
- }
- async function abecadlo () {
- try {
- await costamRobiaceCostam()
- }
- catch (err) {
- console.log('wysypao sie')
- }
- }
- abecadlo()
- ```
Add Comment
Please, Sign In to add comment