Changeset 1127 for trunk/core/lib/Foswiki/OopsException.pm
- Timestamp:
- 12/02/08 12:49:15 (3 years ago)
- File:
-
- 1 edited
-
trunk/core/lib/Foswiki/OopsException.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/lib/Foswiki/OopsException.pm
r1050 r1127 24 24 25 25 throw Foswiki::OopsException( 'bathplugin', 26 status => 418, 26 27 def => 'toestuck', 27 28 web => $web, … … 84 85 my $class = shift; 85 86 my $template = shift; 86 my $this = bless( $class->SUPER::new(), $class);87 my $this = $class->SUPER::new(); 87 88 $this->{template} = $template; 88 89 ASSERT( scalar(@_) % 2 == 0, join( ";", map { $_ || 'undef' } @_ ) ) … … 146 147 } 147 148 148 =begin TML 149 150 ---++ ObjectMethod redirect( $twiki ) 151 152 Generate a redirect to an 'oops' script for this exception. 153 154 If the 'keep' parameter is set in the 155 exception, it saves parameter values into the query as well. This is needed 156 if the query string might get lost during a passthrough, due to a POST 157 being redirected to a GET. 158 159 =cut 160 149 # Generate a redirect to an 'oops' script for this exception. 150 # 151 # If the 'keep' parameter is set in the 152 # exception, it saves parameter values into the query as well. This is needed 153 # if the query string might get lost during a passthrough, due to a POST 154 # being redirected to a GET. 155 # This redirect has been replaced by the generate function below and should 156 # not be called in new code. 161 157 sub redirect { 162 158 my ( $this, $session ) = @_; 163 159 my @p = $this->_prepareResponse($session); 160 my $url = 161 $session->getScriptUrl( 1, 'oops', $this->{web}, $this->{topic}, @p ); 162 $session->redirect( $url, 1 ); 163 } 164 165 =begin TML 166 167 ---++ ObjectMethod generate( $session ) 168 169 Generate an error page for the exception. This will output the error page 170 to the browser. The default HTTP Status for an Oops exception is 500. This 171 can be overridden using the 'status => ' parameter to the constructor. 172 173 =cut 174 175 sub generate { 176 my ($this, $session ) = @_; 177 178 my @p = $this->_prepareResponse( $session ); 179 $session->{response}->status( $this->{status} || 500 ); 180 require Foswiki::UI::Oops; 181 Foswiki::UI::Oops::oops($session, $this->{web}, $this->{topic}, 182 $session->{request}, 0); 183 } 184 185 sub _prepareResponse { 186 my ($this, $session ) = @_; 164 187 my @p = (); 165 188 … … 170 193 my $n = 1; 171 194 push( @p, map { 'param' . ( $n++ ) => $_ } @{ $this->{params} } ); 172 my $url =173 $session->getScriptUrl( 1, 'oops', $this->{web}, $this->{topic}, @p );174 195 while ( my $p = shift(@p) ) { 175 196 $session->{request}->param( -name => $p, -value => shift(@p) ); 176 197 } 177 $session->redirect( $url, 1 );198 return @p; 178 199 } 179 200
Note: See TracChangeset
for help on using the changeset viewer.
