mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-03 22:32:40 +08:00 
			
		
		
		
	PSR-2 try-catch statement
This commit is contained in:
		@ -96,7 +96,7 @@ class Widget extends Component implements ViewContextInterface
 | 
				
			|||||||
            $config['class'] = get_called_class();
 | 
					            $config['class'] = get_called_class();
 | 
				
			||||||
            $widget = Yii::createObject($config);
 | 
					            $widget = Yii::createObject($config);
 | 
				
			||||||
            $out = $widget->run();
 | 
					            $out = $widget->run();
 | 
				
			||||||
        } catch(\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
            // close the output buffer opened above if it has not been closed already
 | 
					            // close the output buffer opened above if it has not been closed already
 | 
				
			||||||
            if(ob_get_level() > 0) {
 | 
					            if(ob_get_level() > 0) {
 | 
				
			||||||
                ob_end_clean();
 | 
					                ob_end_clean();
 | 
				
			||||||
 | 
				
			|||||||
@ -461,7 +461,7 @@ class BaseFileHelper
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            $result = mkdir($path, $mode);
 | 
					            $result = mkdir($path, $mode);
 | 
				
			||||||
            chmod($path, $mode);
 | 
					            chmod($path, $mode);
 | 
				
			||||||
        } catch(\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
            throw new \yii\base\Exception("Failed to create directory '$path': " . $e->getMessage(), $e->getCode(), $e);
 | 
					            throw new \yii\base\Exception("Failed to create directory '$path': " . $e->getMessage(), $e->getCode(), $e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -658,7 +658,7 @@ class Formatter extends Component
 | 
				
			|||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                return new DateTime($value, new DateTimeZone($this->defaultTimeZone));
 | 
					                return new DateTime($value, new DateTimeZone($this->defaultTimeZone));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } catch(\Exception $e) {
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
            throw new InvalidParamException("'$value' is not a valid date time value: " . $e->getMessage()
 | 
					            throw new InvalidParamException("'$value' is not a valid date time value: " . $e->getMessage()
 | 
				
			||||||
                . "\n" . print_r(DateTime::getLastErrors(), true), $e->getCode(), $e);
 | 
					                . "\n" . print_r(DateTime::getLastErrors(), true), $e->getCode(), $e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user