log error python in try catch code example
Example 1: axios try catch get error status cocxe
try {
await axios.get('/bad-call')
} catch (error) {
const err = error as AxiosError
if (err.response) {
console.log(err.response.status)
console.log(err.response.data)
}
this.handleAxiosError(error)
}
Example 2: try catch python with open
import os ,csv
# Created to ensure file/dataset are being load properly
# Place below your filename with .csv where 'x' is .
data = open('x', 'r')
while True:
try:
if data == open('x'):
print('file is open')
except IOError:
print('Unable to load files')
break