66 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			66 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/php
 | |
| <?php
 | |
| require __DIR__."/../vendor/autoload.php";
 | |
| 
 | |
| use nulib\app\cli\Application;
 | |
| use nulib\exceptions;
 | |
| use nulib\output\msg;
 | |
| use nulib\UserException;
 | |
| 
 | |
| Application::run(new class extends Application {
 | |
|   const ARGS = [
 | |
|     "purpose" => "tester l'affichage des exception",
 | |
| 
 | |
|     "merge" => parent::ARGS,
 | |
|   ];
 | |
| 
 | |
|   function fart(): void {
 | |
|     throw new RuntimeException("fart");
 | |
|   }
 | |
| 
 | |
|   function prout(): void {
 | |
|     try {
 | |
|       $this->fart();
 | |
|     } catch (Exception $e) {
 | |
|       throw new RuntimeException("prout", $e->getCode(), $e);
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   function main() {
 | |
|     try {
 | |
|       throw new Exception("exception normale");
 | |
|     } catch (Exception $e) {
 | |
|       msg::info("summary: ". exceptions::get_summary($e));
 | |
|       msg::error($e);
 | |
|     }
 | |
|     try {
 | |
|       try {
 | |
|         $this->prout();
 | |
|       } catch (Exception $e) {
 | |
|         throw new Exception("exception normale", $e->getCode(), $e);
 | |
|       }
 | |
|     } catch (Exception $e) {
 | |
|       msg::info("summary: ". exceptions::get_summary($e));
 | |
|       msg::error($e);
 | |
|     }
 | |
|     try {
 | |
|       throw exceptions::invalid_value("valeur", $kind)
 | |
|         ->setTechMessage("message technique");
 | |
|     } catch (Exception $e) {
 | |
|       msg::info("summary: ". exceptions::get_summary($e));
 | |
|       msg::error($e);
 | |
|     }
 | |
|     try {
 | |
|       try {
 | |
|         $this->prout();
 | |
|       } catch (Exception $e) {
 | |
|         throw exceptions::invalid_value("valeur", $kind, null, $e)
 | |
|           ->setTechMessage("message technique");
 | |
|       }
 | |
|     } catch (Exception $e) {
 | |
|       msg::info("summary: ". exceptions::get_summary($e));
 | |
|       msg::error($e);
 | |
|     }
 | |
|   }
 | |
| });
 |