Throw [v1.1.04+]

¿¡·¯ÀÇ ÃâÇöÀ» ¾Ë·ÁÁÝ´Ï´Ù. ÀÌ ½ÅÈ£´Â try-catch ¼­¼ú¹®À¸·Î ÀâÀ» ¼ö ÀÖ½À´Ï´Ù.

Throw [, Expression]

¸Å°³º¯¼ö

Expression

catchÀÇ OutputVar¿¡ ÀúÀåÇÒ °ª.

ÀÌ ¸Å°³º¯¼ö´Â Ç¥Çö½ÄÀ̱⠶§¹®¿¡, ´ÙÀ½Àº ¸ðµÎ À¯È¿ÇÑ ¿¹Á¦ÀÔ´Ï´Ù:

throw 3
throw "literal string"
throw MyVar
throw i + 1
throw { what: "Custom error", file: A_LineFile, line: A_LineNumber } ; °´Ã¼¸¦ ´øÁý´Ï´Ù.

ÀÌ ¸Å°³º¯¼ö´Â ¾ðÁ¦³ª Ç¥Çö½ÄÀÔ´Ï´Ù. ±×·¡¼­ º¯¼ö ÂüÁ¶´Â ÆÛ¼¾Æ® »çÀÎÀ¸·Î µÑ·¯½Î¸é ¾È µË´Ï´Ù. ´Ü, double-deref¸¦ ¼öÇàÇÒ ¶§´Â ¿¹¿ÜÀÔ´Ï´Ù.

[v1.1.05+]: »ý·«µÇ¸é, ±âº» ¸Þ½ÃÁö¿Í ÇÔ²² ¿¹¿Ü °´Ã¼°¡ ´øÁ®Áý´Ï´Ù.

Exception(Message [, What, Extra])

´ÙÀ½ Ư¼ºÀ» °¡Áø °´Ã¼¸¦ ¸¸µì´Ï´Ù. ¶ÇÇÑ ½ÇÇà½Ã°£ ¿¡·¯°¡ ¸¸µç ¿¹¿Ü¿¡ ÈçÇÕ´Ï´Ù:

WhatÀÌ »ý·«µÇ¸é, ÇöÀç ÇÔ¼ö³ª ¼­ºê·çƾÀÇ À̸§ÀÌ ±âº»°ªÀÌ µË´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é ¹®ÀÚ¿­À̰ųª ¶Ç´Â È£Ãâ ½ºÅÃÀÇ À§ÂÊÀ¸·ÎºÎÅÍ ¾Æ·¡·Î À½ÀÇ ¿ÀÇÁ¼ÂÀÏ ¼ö ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, °ªÀÌ -1À̸é Exception.What¿¡ ÇöÀç ÇÔ¼ö³ª ¼­ºê·çƾÀ» ¼³Á¤ÇÏ°í Exception.Line¿¡ ±×¸¦ È£ÃâÇÑ ÁÙÀ» ¼³Á¤ÇÕ´Ï´Ù. ±×·¸Áö¸¸, ½ºÅ©¸³Æ®°¡ ÄÄÆÄÀÏ µÇ¾ú°Å³ª ¿ÀÇÁ¼ÂÀÌ À¯È¿ÇÏÁö ¾ÊÀ¸¸é, WhatÀº ±×³É ¹®ÀÚ¿­·Î º¯È¯µË´Ï´Ù.

Message¿Í Extra´Â ¹®ÀÚ¿­·Î º¯È¯µË´Ï´Ù. À̰͵éÀº ¿¹¿Ü°¡ ´øÁ®Á³´Âµ¥ ÀâÁö ¸øÇÏ¸é ¿¡·¯ ´ëÈ­»óÀÚ¿¡ º¸¿©Áý´Ï´Ù.

try
    BadlyCodedFunc()
catch e
    MsgBox % "Error in " e.What ", which was called at line " e.Line 

BadlyCodedFunc() {
    throw Exception("Fail", -1)
}

°ü·Ã Ç׸ñ

Try, Catch, Finally

¿¹Á¦

Try¸¦ ÂüÁ¶ÇϽʽÿÀ.