catchErrors.js 390 Bytes
Newer Older
kusang96's avatar
dd    
kusang96 committed
1
2
function catchErrors(error, displayError) {
    let errorMsg
이재연's avatar
aa    
이재연 committed
3

kusang96's avatar
dd    
kusang96 committed
4
5
    if (error.response) {
        errorMsg = error.response.data
이재연's avatar
aa    
이재연 committed
6
        console.log(errorMsg)
kusang96's avatar
dd    
kusang96 committed
7
8
    } else if (error.request) {
        errorMsg = error.request
이재연's avatar
aa    
이재연 committed
9
        console.log(errorMsg)
kusang96's avatar
dd    
kusang96 committed
10
11
    } else {
        errorMsg = error.message
이재연's avatar
aa    
이재연 committed
12
        console.log(errorMsg)
kusang96's avatar
dd    
kusang96 committed
13
14
15
16
    }
    displayError(errorMsg)
}

17
export default catchErrors