~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to phabricator/src/aphront/response/AphrontUnhandledExceptionResponse.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2015-01-29 00:15:58 UTC
  • mfrom: (0.14.1) (0.13.1) (0.10.2) (2.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20150129001558-7qklhtcc043y9mog
Tags: 0~git20150129-1
* New snapshot release
* restricted access to local config file (closes: #775479)
* moved local config file to /var/lib/phabricator (closes: #775478)
* switched mysql-server dependency to recommends (closes: #773536)
* use /run instead of /var/run (closes: #775803)
* prevent package reinstall from overwritting local changes (closes: #776288)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
final class AphrontUnhandledExceptionResponse
 
4
  extends AphrontStandaloneHTMLResponse {
 
5
 
 
6
  private $exception;
 
7
 
 
8
  public function setException(Exception $exception) {
 
9
    $this->exception = $exception;
 
10
    return $this;
 
11
  }
 
12
 
 
13
  public function getHTTPResponseCode() {
 
14
    return 500;
 
15
  }
 
16
 
 
17
  protected function getResources() {
 
18
    return array(
 
19
      'css/application/config/config-template.css',
 
20
      'css/application/config/unhandled-exception.css',
 
21
    );
 
22
  }
 
23
 
 
24
  protected function getResponseTitle() {
 
25
    return pht('Unhandled Exception');
 
26
  }
 
27
 
 
28
  protected function getResponseBodyClass() {
 
29
    return 'unhandled-exception';
 
30
  }
 
31
 
 
32
  protected function getResponseBody() {
 
33
    $ex = $this->exception;
 
34
 
 
35
    if ($ex instanceof AphrontUsageException) {
 
36
      $title = $ex->getTitle();
 
37
    } else {
 
38
      $title = get_class($ex);
 
39
    }
 
40
 
 
41
    $body = $ex->getMessage();
 
42
    $body = phutil_escape_html_newlines($body);
 
43
 
 
44
    return phutil_tag(
 
45
      'div',
 
46
      array(
 
47
        'class' => 'unhandled-exception-detail',
 
48
      ),
 
49
      array(
 
50
        phutil_tag(
 
51
          'h1',
 
52
          array(
 
53
            'class' => 'unhandled-exception-title',
 
54
          ),
 
55
          $title),
 
56
        phutil_tag(
 
57
          'div',
 
58
          array(
 
59
            'class' => 'unhandled-exception-body',
 
60
          ),
 
61
          $body),
 
62
      ));
 
63
  }
 
64
 
 
65
  protected function buildPlainTextResponseString() {
 
66
    $ex = $this->exception;
 
67
 
 
68
    return pht(
 
69
      '%s: %s',
 
70
      get_class($ex),
 
71
      $ex->getMessage());
 
72
  }
 
73
 
 
74
}