This should be added to the documentation... I worked around this by looking for the file and returning 404, but it was not nearly as elegant.
-m On Wed, Mar 05, 2008 at 10:33:06AM -0800, Ian Burrell wrote: > On Thu, Feb 28, 2008 at 7:36 PM, Hans Dieter Pearcey <[EMAIL PROTECTED]> > wrote: > > > > On Thu, Feb 28, 2008 at 05:47:20PM -0800, Ian Burrell wrote: > > > We use a subclass of HTML::Mason::CGIHandler. How do we get 404 > > > errors instead of fatal errors when the component is not found? It > > > looks like HTML::Mason::ApacheHandler has special code to detect > > > TopLevelNotFound errors and turn them into 404's (or at least comments > > > about what to override). What do we need to override in CGIHandler to > > > return 404's? > > > > I think what ApacheHandler really relies on is trying to resolve the path > > to a > > component before doing any execution. The TopLevelNotFound errors are > > caught, > > but my guess (only a guess) is that that's just a backup, for some weird > > edge > > case. > > > > Doing the same thing with CGIHandler seems pretty reasonable to me. > > There's > > nothing to override, though, because CGIHandler does less than Apache. > > > > For anyone that is curious, it was easy to extend our CGIHandler and > Request sub-class to give 404 HTTP errors instead of going through > normal mason error handling. > > The Request sub-class overrides _handle_error to rethrow > TopLevelNotFound errors. > > sub _handle_error > { > my ($self, $err) = @_; > rethrow_exception($err) if $self->is_subrequest; > > if (isa_mason_exception($err, 'TopLevelNotFound')) { > rethrow_exception($err); > } > $self->SUPER::_handle_error($err); > } > > The CGIHandler sub-class overrides handle_cgi_object to turn > TopLevelNotFound into 404 status. > > sub handle_cgi_object > { > my ($self, $cgi) = @_; > eval { > $self->SUPER::handle_cgi_object($cgi); > }; > if (my $err = $@) { > if (isa_mason_exception($err, 'TopLevelNotFound')) { > return NOT_FOUND; > } > else { > rethrow_exception($err); > } > } > } > > Our CGI script returns the 404 status back to the browser. > > - Ian > > > > > - Ian > > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users