"Try-catch"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 2개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;try-catch, throw
;try-catch, throw
;try except
;try except
==JavaScript==
[[category: JavaScript]]
<syntaxhighlight lang='JavaScript'>
try {
    asdfasdf("Welcome guest!");
}
catch(err) {
    console.log( err.message );
}
</syntaxhighlight>
* 새로운 블럭을 만들지 않고 .then, .catch로도 대체할 수 있습니다.


==Python==
==Python==
[[category:python]]
[[category:python]]
<source lang='Python'>
<syntaxhighlight lang='Python'>
try:
try:
try:
try:
14번째 줄: 26번째 줄:
print('IOError')
print('IOError')
# IOError
# IOError
</source>
</syntaxhighlight>
<source lang='Python'>
<syntaxhighlight lang='Python'>
try:
try:
try:
try:
24번째 줄: 36번째 줄:
print('IOError')
print('IOError')
# ZeroDivisionError
# ZeroDivisionError
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:31 기준 최신판

try-catch, throw
try except

1 JavaScript[ | ]

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

2 Python[ | ]

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

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}