반응형
const CustomError = (message) => {
//객체로 오류 상태를 던지도록 한다
this.message = message
this.type = 'NotImageFileException'
}
try {
const imgTypes = ['.jpg','.png']
const fileName = 'node.doc'
const isImageFile = imgTypes.find(ext => fileName.endWith(item))
if(!isImageFile){
throw new CustomError('this is not a image file')
//throw new 'this is not a image file'
}
}catch(e){
console.log(e)
}
반응형
'NodeJs' 카테고리의 다른 글
class (0) | 2020.01.10 |
---|---|
arrow function (0) | 2020.01.10 |
event emitter (0) | 2020.01.10 |
setInterval (0) | 2020.01.10 |
IIFE (0) | 2020.01.10 |