Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • BeforeControlEvent
  • BeforeProcessEvent
  • BeforeValidateEvent
  • ControlEvent
  • ControlEventBase
  • Dispatcher
  • FailureEvent
  • GetFormEvent
  • ProcessEvent
  • RescueEvent
  • Response
  • ValidateEvent
  • ValidateEventBase

Exceptions

  • Failure
  • FormHasExpired

Functions

  • array_to_xml
 1 <?php
 2 
 3 /*
 4  * This file is part of the ICanBoogie package.
 5  *
 6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
 7  *
 8  * For the full copyright and license information, please view the LICENSE
 9  * file that was distributed with this source code.
10  */
11 
12 namespace ICanBoogie\Operation;
13 
14 use ICanBoogie\Operation;
15 use ICanBoogie\PropertyNotDefined;
16 
17 /**
18  * Exception raised when an operation fails.
19  *
20  * @property-read Operation $operation The operation that failed.
21  */
22 class Failure extends \ICanBoogie\HTTP\HTTPError
23 {
24     private $operation;
25 
26     public function __construct(Operation $operation, \Exception $previous=null)
27     {
28         $this->operation = $operation;
29 
30         $message = $this->format_message($operation);
31         $code = $operation->response->status;
32 
33         parent::__construct($message, $code, $previous);
34     }
35 
36     protected function format_message(Operation $operation)
37     {
38         $message = $operation->response->message ?: "The operation failed.";
39 
40         if ($operation->response->errors->count())
41         {
42             $message .= "\n\nThe following errors where raised:";
43 
44             foreach ($operation->response->errors as $id => $error)
45             {
46                 if ($error === true)
47                 {
48                     continue;
49                 }
50 
51                 $message .= "\n– $error";
52             }
53         }
54 
55         return $message;
56     }
57 
58     public function __get($property)
59     {
60         if ($property == 'operation')
61         {
62             return $this->operation;
63         }
64 
65         throw new PropertyNotDefined(array($property, $this));
66     }
67 }
Autodoc API documentation generated by ApiGen 2.8.0