File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 55// http://opensource.org/licenses/MIT>, at your option. This file may not be
66// copied, modified, or distributed except according to those terms.
77
8+ use std:: error:: Error ;
9+ use std:: fmt:: { Display , Formatter , Result as FmtResult } ;
810use std:: io;
911use std:: ops:: Deref ;
1012use std:: os:: raw:: c_void;
@@ -21,6 +23,32 @@ pub enum StackError {
2123 IoError ( io:: Error ) ,
2224}
2325
26+ impl Display for StackError {
27+ fn fmt ( & self , fmt : & mut Formatter ) -> FmtResult {
28+ match * self {
29+ StackError :: ExceedsMaximumSize ( size) => {
30+ write ! ( fmt, "Requested more than max size of {} bytes for a stack" , size)
31+ } ,
32+ StackError :: IoError ( ref e) => e. fmt ( fmt) ,
33+ }
34+ }
35+ }
36+
37+ impl Error for StackError {
38+ fn description ( & self ) -> & str {
39+ match * self {
40+ StackError :: ExceedsMaximumSize ( _) => "exceeds maximum stack size" ,
41+ StackError :: IoError ( ref e) => e. description ( ) ,
42+ }
43+ }
44+ fn cause ( & self ) -> Option < & Error > {
45+ match * self {
46+ StackError :: ExceedsMaximumSize ( _) => None ,
47+ StackError :: IoError ( ref e) => Some ( e) ,
48+ }
49+ }
50+ }
51+
2452/// Represents any kind of stack memory.
2553///
2654/// `FixedSizeStack` as well as `ProtectedFixedSizeStack`
You can’t perform that action at this time.
0 commit comments