Try-catch

try-catch, throw
try except

1 JavaScript[ | ]

JavaScript
Copy
try {
    asdfasdf("Welcome guest!");
}
catch(err) {
    console.log( err.message );
}
  • 새로운 블럭을 만들지 않고 .then, .catch로도 대체할 수 있습니다.

2 Python[ | ]

Python
Copy
try:
	try:
		open('.')
	except ZeroDivisionError:
		print('ZeroDivisionError')
except IOError:
	print('IOError')
# IOError
Python
Copy
try:
	try:
		1/0
	except ZeroDivisionError:
		print('ZeroDivisionError')
except IOError:
	print('IOError')
# ZeroDivisionError

3 같이 보기[ | ]