Small util for convenient error handling.
npm install @42px/custom-errorsimport{createCustomError}from'@42px/custom-errors'import{findRoom,doRoomStuff,showError}from'rooms'constRoomNotFound=createCustomError('RoomNotFound')asyncfunctionfindAndProceed(id){constroom=awaitfindRoom(id)if(!room){thrownewRoomNotFound()}doRoomStuff(room)}findAndProceed(1).catch((err)=>{if(err.name==='RoomNotFound')showError('Sorry, room not found')})