Allow non-mahara exceptions to show a bit more detail

Bug #1855771 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Wishlist
Robert Lyon

Bug Description

When you see errors like:

[WAR] 9c (lib/errors.php:536) [ParseError]: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION)
 Call stack (most recent first):
   * exception(object(ParseError)) at Unknown:0

It is not obvious to where the problem is - especially if you are cherry-picking in a bunch of patches and so are not familiar with the code

With PHP Exception class there are some bits we can harness to help up
https://www.php.net/manual/en/class.exception.php

The getFile() and getLine() methods will be useful

Robert Lyon (robertl-9)
Changed in mahara:
importance: Undecided → Wishlist
status: New → In Progress
assignee: nobody → Robert Lyon (robertl-9)
milestone: none → 20.04.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/10661

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "19.10_STABLE" branch: https://reviews.mahara.org/10674

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/10661
Committed: https://git.mahara.org/mahara/mahara/commit/9b35263dde89fb94b74b11806ae028dd2d83ff45
Submitter: Cecilia Vela Gurovic (<email address hidden>)
Branch: master

commit 9b35263dde89fb94b74b11806ae028dd2d83ff45
Author: Robert Lyon <email address hidden>
Date: Tue Dec 10 09:12:34 2019 +1300

Bug 1855771: Allow generic system errors to give more detail

So that we can debug things easier

The Exception class has two useful methods, getFile() and getLine()
so we can use these to dispaly where the problem is rather than just
a generic: exception(object(ParseError)) at Unknown:0

To test:
- a syntax mistake - add a log_debug() line before the first function in a class
and see if the error shows the correct file/line
- MaharaException - add the following line somewher ein the code
throw new MaharaException("Missing bananas");
and see if the error shows the correct file/line

behatnotneeded

Change-Id: I5a254f842ab6444ebb324e11e2c93d1c44e3e1d3
Signed-off-by: Robert Lyon <email address hidden>

Changed in mahara:
status: In Progress → Fix Committed
tags: added: nominatedfeature
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.