tillmo / two_tiered_quiz

A multiple choice quiz with justifications for the answers, written in Django
GNU Affero General Public License v3.0
0 stars 0 forks source link

Properly display unforeseen backend errors #43

Closed tillmo closed 4 years ago

tillmo commented 4 years ago

Backend errors, e.g. during sign up, are displayed using a snackbar in the frontend. However, some errors are not displayed properly. E.g. instead of the true error message

OperationalError at /rest-auth/login/ attempt to write a readonly database
Request Method: POST
Request URL: http://quiz.iks.cs.ovgu.de:8000/rest-auth/login/
Django Version: 2.2.11
Python Executable: /usr/bin/python3 
[...]

I got

0 - O

1 - p

2 - e

3 - r

4 - a

5 - t

6 - i

7 - o

8 - n

9 - a

10 - l

11 - E

12 - r

13 - r

14 - o

15 - r

16 -
17 - a

18 - t

19 -
20 - /

21 - r

22 - e

23 - s

24 - t
[...]
pramodbontha commented 4 years ago

@tillmo I am not able to replicate the issue. Could you please give me an example data you tried

pramodbontha commented 4 years ago

@tillmo Was able to replicate the issue. The error it is showing is that

''OperationalError at /rest-auth/registration/ attempt to write a readonly database''

Is the database in readonly mode on server?

tillmo commented 4 years ago

The database problem is @jelmd's business, see #44. Here, the point is to properly display unforseen error messages.

tillmo commented 4 years ago

You can test your locally running frontend by having quiz.iks.cs.ovgu.de:8000 as backend. Here is the needed patch:

diff --git a/frontend/lqclient/src/components/Authentication/SignUp.jsx b/frontend/lqclient/src/components/Authentication/SignUp.jsx
index 4c43a56..f0299e8 100644
--- a/frontend/lqclient/src/components/Authentication/SignUp.jsx
+++ b/frontend/lqclient/src/components/Authentication/SignUp.jsx
@@ -71,7 +71,7 @@ export class SignUp extends Component {
     this.setState({ openBackDrop: true });
     axios
     .post(
-        "http://127.0.0.1:8000/rest-auth/registration/",
+        "http://quiz.iks.cs.ovgu.de:8000/rest-auth/registration/",
         this.state.formData
       )
     .then(res => {
diff --git a/frontend/lqclient/src/components/QuizPage/QuizDescription.jsx b/frontend/lqclient/src/components/QuizPage/QuizDescription.jsx
index 893ce07..e95926f 100644
--- a/frontend/lqclient/src/components/QuizPage/QuizDescription.jsx
+++ b/frontend/lqclient/src/components/QuizPage/QuizDescription.jsx
@@ -17,7 +17,7 @@ export class QuizDescription extends Component {
   if (HasSessionExpired()) {
       this.props.history.push("/");
     } else {
-      axios.get("http://127.0.0.1:8000/api/").then(res => {
+      axios.get("http://quiz.iks.cs.ovgu.de:8000/api/").then(res => {
         this.setState({ cardDetails: res.data });
       });
     }
diff --git a/frontend/lqclient/src/components/QuizPage/QuizQuestion.jsx b/frontend/lqclient/src/components/QuizPage/QuizQuestion.jsx
index 17b2dd1..5522e12 100644
--- a/frontend/lqclient/src/components/QuizPage/QuizQuestion.jsx
+++ b/frontend/lqclient/src/components/QuizPage/QuizQuestion.jsx
tillmo commented 4 years ago

fixed by #46