i n s o l i d a r i t y w i t h t h e p e o p l e o f f e
play

I n s o l i d a r i t y w i t h t h e p e o p - PowerPoint PPT Presentation

I n s o l i d a r i t y w i t h t h e p e o p l e o f F e r g u s o n a n d t h e i r p r o t e s t s a g a i n s t p o l i c e v i o l e n c e H o w t o M a k e E r


  1. I n s o l i d a r i t y w i t h t h e p e o p l e o f F e r g u s o n a n d t h e i r p r o t e s t s a g a i n s t p o l i c e v i o l e n c e

  2. H o w t o M a k e E r r o r H a n d l i n g L e s s E r r o r - P r o n e o r . . . Rescuing error handling ideas from the 1970s! “ B a c k t o t h e F u t u r e ™ ” i s a t r a d e ma r k o f U n i v e r s a l C i t y S t u d i o s , I n c . a n d A mb l i n E n t e r t a i n me n t , I n c . I a m c l a i mi n g f a i r u s e o f t h i s t r a d e ma r k a n d l o g o . I ma g e f r o m f u s i o n - i n d u s t r i e s 1 . t r i p o d . c o m.

  3. H o w t o M a k e E r r o r H a n d l i n g L e s s E r r o r - P r o n e I n t r o d u c t i o n S e q u e n t i a l e r r o r h a n d l i n g E r r o r s t a t u s , r e t u r n c o d e s , e r r o r v a l u e s , h a n d l e r s E x c e p t i o n s R e c o v e r y b l o c k s R o l l b a c k e r r o r r e c o v e r y M o t i v a t i o n O p t i mi s a t i o n s S y n e r g y w i t h o t h e r f e a t u r e s C o n c u r r e n t e r r o r h a n d l i n g O u t p u t v a l i d i t y T h e K e n p r o t o c o l P r o mi s e s

  4. I n t r o d u c t i o n “ E r r o r ” c o me s f r o m a L a t i n v e r b me a n i n g “ t o s t r a y ” . F o r o u r p u r p o s e s , e r r o r s a r e c a s e s w h e r e t h e e x e c u t i o n o f a p r o g r a m s t r a y s f r o m i t s u s u a l p a t h . We ’ l l b e c o n s i d e r i n g e r r o r s i n r e l a t i o n t o h i g h - l e v e l l a n g u a g e p r o g r a mmi n g a n d d i s t r i b u t e d s y s t e ms . E r r o r s a t o t h e r l a y e r s – o p e r a t i n g s y s t e ms , h a r d w a r e , e t c . – a r e i mp o r t a n t b u t n o t w h a t t h i s t a l k i s f o c u s s e d o n . T h i s i n c l u d e s : c a s e s t h a t t h e l a n g u a g e o r p r o g r a m d e f i n e s t o b e e r r o r s ; c a s e s w h e r e t h e l a n g u a g e i mp l e me n t a t i o n o r p r o g r a m i s u n a b l e t o me e t i t s s p e c i f i c a t i o n . E r r o r h a n d l i n g i s t h e r e s p o n s e t o e r r o r s . A n e r r o r h a n d l i n g m e c h a n i s m i s a f e a t u r e o f a l a n g u a g e d e s i g n e d t o e n a b l e r e s p o n d i n g t o e r r o r s . A n e r r o r h a n d l i n g p a t t e r n i s a p a t t e r n o f u s e o f a l a n g u a g e t o r e s p o n d ( o r n o t ! ) t o e r r o r s . T h i s t a l k i s a b o u t e n g i n e e r i n g o f e r r o r h a n d l i n g me c h a n i s ms a n d p a t t e r n s f o r d e p e n d a b i l i t y . D e p e n d a b i l i t y me a n s c o n s i s t e n t l y d o i n g s o me t h i n g r e a s o n a b l e , t h a t o t h e r c o d e o r a u s e r c o u l d d e p e n d o n , i n t h e f a c e o f p o t e n t i a l e r r o r s . L e t ’ s c o n s i d e r s o me c o mmo n e r r o r h a n d l i n g me c h a n i s ms a n d p a t t e r n s , a n d w h a t c a n g o w r o n g w i t h t h e m.

  5. E r r o r s t a t e H o l d t h e “ l a s t e r r o r ” i n a p e r - p r o c e s s o r p e r - t h r e a d v a r i a b l e . M a y b e a c c e s s i t v i a a f u n c t i o n , ma y b e d i r e c t l y . U s e d i n : C / U n i x ( e r r n o ) ; Wi n d o w s A P I ( G e t L a s t E r r o r ) ; P e r l ( y o u d o n ’ t w a n t t o k n o w ) ; P H P ( e r r o r _ g e t _ l a s t ) ; v a r i o u s s h e l l l a n g u a g e s P r o b l e ms : P r o g r a mme r s ma y mi s u n d e r s t a n d t h e d e f i n e d c o n v e n t i o n s f o r u s e o f t h e s t a t e v a r i a b l e , w h i c h a r e o f t e n s u b t l e o r b a d l y d o c u me n t e d . F o r e x a mp l e , P O S I X s a y s : “ T h e s e t t i n g o f e r r n o a f t e r a s u c c e s s f u l c a l l t o a f u n c t i o n i s u n s p e c i f i e d u n l e s s t h e d e s c r i p t i o n o f t h a t f u n c t i o n s p e c i f i e s t h a t e r r n o s h a l l n o t b e mo d i f i e d . ” S o t h e c o mmo n l y u s e d p a t t e r n ( r e c o mme n d e d i n f o o t n o t e 2 0 2 o f t h e C 9 9 a n d C 1 1 s t a n d a r d s ) o f s e t t i n g e r r n o t o z e r o b e f o r e a f u n c t i o n c a l l a n d t h e n c h e c k i n g t h a t i t i s n o n - z e r o a f t e r w a r d i s i n c o r r e c t ; i n a l mo s t a l l c a s e s i t ’ s n e c e s s a r y t o c h e c k t h e r e t u r n v a l u e a f t e r e a c h c a l l i n s t e a d . Wi n d o w s ’ G e t L a s t E r r o r i s e v e n l e s s c o n s i s t e n t t h a n t h i s . T h e p a t h o f l e a s t r e s i s t a n c e i s t o o mi t c h e c k i n g f o r a n e r r o r . T h i s i s v e r y c o mmo n i n C a n d Wi n d o w s p r o g r a ms . I n “ c l e a n u p ” c o d e b e f o r e a n e r r o r i s p r o p a g a t e d t o t h e c a l l e r , a n o t h e r o p e r a t i o n mi g h t c l o b b e r t h e e r r o r s t a t e . L a n g u a g e s t h a t r e q u i r e l e s s e x p l i c i t c l e a n u p a r e i n a b e t t e r p o s i t i o n h e r e . B e c a u s e e r r o r c h e c k i n g i s p r o g r a mme d e x p l i c i t l y , i t ' s e a s y t o g e t i t w r o n g .

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend