source: trunk/ab5.0/ablib/src/Classes/System/IO/Exception.ab

Last change on this file was 605, checked in by イグトランス (egtra), 16 years ago

非同期入出力(Begin/End-Read/Writeメソッド)を実装。

File size: 3.2 KB
Line 
1/*!
2@file
3@brief System.IOに属す例外クラスの定義
4*/
5
6Namespace ActiveBasic
7
8Const AB_E_IO = &h80041620 '80131620
9Const AB_E_FILENOTFOUND = STG_E_FILENOTFOUND '0x80070002
10
11End Namespace
12
13Namespace System
14Namespace IO
15
16/*!
17@brief IO処理に関する例外のクラス
18@author Egtra
19@date 2007/12/06
20*/
21Class IOException
22 Inherits SystemException
23Public
24 /*!
25 @biref コンストラクタ
26 */
27 Sub IOException()
28 SystemException(GetType().FullName)
29 HResult = ActiveBasic.AB_E_IO
30 End Sub
31 /*!
32 @biref コンストラクタ
33 @param[in] message エラーメッセージ
34 */
35 Sub IOException(message As String)
36 SystemException(message)
37 HResult = ActiveBasic.AB_E_IO
38 End Sub
39 /*!
40 @biref コンストラクタ
41 @param[in] message エラーメッセージ
42 @param[in] innerException 内部例外
43 */
44 Sub IOException(message As String, innerException As Exception)
45 SystemException(message, innerException)
46 HResult = ActiveBasic.AB_E_IO
47 End Sub
48 /*!
49 @biref コンストラクタ
50 @param[in] message エラーメッセージ
51 @param[in] hr HRESULT例外値
52 */
53 Sub IOException(message As String, hr As HRESULT)
54 SystemException(message)
55 HResult = hr
56 End Sub
57End Class
58
59Namespace Detail
60 /*!
61 @brief Windowsエラー値を基にIOExceptionを投げる。
62 @param[in] message エラーメッセージ
63 @param[in] error エラーコード
64 @author Egtra
65 @date 2007/12/06
66 */
67 Sub ThrowWinIOException(msg As String, error As DWord)
68 Throw GetWinIOException(msg, error)
69 End Sub
70
71 /*!
72 @brief Windowsエラー値を基にIOExceptionインスタンスを作成する。
73 @param[in] message エラーメッセージ
74 @param[in] error エラーコード
75 @return 作成されたIOExceptionインスタンス
76 @author Egtra
77 @date 2008/08/21
78 */
79 Function GetWinIOException(msg As String, error As DWord) As IOException
80 Return New IOException(msg, HRESULT_FROM_WIN32(error))
81 End Function
82
83 /*!
84 @brief GetLastError()の値を基にIOExceptionを投げる。
85 @param[in] message エラーメッセージ
86 @author Egtra
87 @date 2007/12/06
88 */
89 Sub ThrowWinLastErrorIOException(msg = Nothing As String)
90 Throw GetWinLastErrorIOException(msg)
91 End Sub
92
93
94 /*!
95 @brief GetLastError()の値を基にIOExceptionインスタンスを作成する。
96 @param[in] message エラーメッセージ
97 @return 作成されたIOExceptionインスタンス
98 @author Egtra
99 @date 2008/08/21
100 */
101 Function GetWinLastErrorIOException(msg As String) As IOException
102 Return New IOException(msg, HRESULT_FROM_WIN32(GetLastError()))
103 End Function
104End Namespace
105
106
107/*!
108@brief ディスク上に指定したファイル名が見つからない際の例外
109@author NoWest
110@date 2008/08/11
111*/
112Class FileNotFoundException
113 Inherits SystemException
114Public
115 /*!
116 @biref コンストラクタ
117 */
118 Sub FileNotFoundException()
119 SystemException(GetType().FullName)
120 HResult = ActiveBasic.AB_E_FILENOTFOUND
121 End Sub
122 /*!
123 @biref コンストラクタ
124 @param[in] message エラーメッセージ
125 */
126 Sub FileNotFoundException(message As String)
127 SystemException(message)
128 HResult = ActiveBasic.AB_E_FILENOTFOUND
129 End Sub
130 /*!
131 @biref コンストラクタ
132 @param[in] message エラーメッセージ
133 @param[in] innerException 内部例外
134 */
135 Sub FileNotFoundException(message As String, innerException As Exception)
136 SystemException(message, innerException)
137 HResult = ActiveBasic.AB_E_FILENOTFOUND
138 End Sub
139End Class
140
141End Namespace 'IO
142End Namespace 'System
Note: See TracBrowser for help on using the repository browser.