Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChaliceViewError Should Print Real Error #50

Closed
woodlandh opened this issue Jul 15, 2016 · 1 comment
Closed

ChaliceViewError Should Print Real Error #50

woodlandh opened this issue Jul 15, 2016 · 1 comment

Comments

@woodlandh
Copy link

woodlandh commented Jul 15, 2016

tl;dr ChaliceViewError should print the underlying error message instead of hiding it (I think?)

[heavily edited]

By default, ChaliceViewError does not raise the underlying exception, it only prints "An internal server error occurred."
When app.debug = True, ChaliceViewError instead raises the underlying exception.

I think both of these features should be enabled at the same time. ChaliceViewError should print the real message (so that it is logged in CloudWatch) and then return a nicely-wrapped ChaliceViewError to the client. This way the developer can get errors logged without worrying about 'null' returns on bad requests.

I've had to do this to gain this functionality:
except Exception as e: print(e) raise e

And still every single error just gets raised as

Traceback (most recent call last): File "/var/task/chalice/__init__.py", line 148, in __call__ raise e
Which isn't helpful.

@woodlandh woodlandh changed the title Debug Mode - Need to Investigate ChaliceViewError ChaliceViewError Should Print Real Error Jul 17, 2016
@jamesls
Copy link
Member

jamesls commented Jul 22, 2016

Your suggestion of printing/logging the exception on the case of error I think makes a lot of sense.

jamesls added a commit to jamesls/chalice that referenced this issue Aug 1, 2016
Before:

```
{
    "errorMessage": "Raising an exception!",
    "errorType": "RuntimeError",
    "stackTrace": [
        [
            "/var/task/chalice/__init__.py",
            198,
            "__call__",
            "raise e"
        ]
    ]
}
```

After:
```
{
    "errorMessage": "Raising an exception!",
    "errorType": "RuntimeError",
    "stackTrace": [
        [
            "/var/task/chalice/__init__.py",
            192,
            "__call__",
            "response = view_function(*function_args)"
        ],
        [
            "/var/task/app.py",
            9,
            "index",
            "return a()"
        ],
        [
            "/var/task/app.py",
            12,
            "a",
            "return b()"
        ],
        [
            "/var/task/app.py",
            15,
            "b",
            "raise RuntimeError(\"Raising an exception!\")"
        ]
    ]
}
```

This also shows up in `chalice logs`:

```
2016-08-01 16:14:06.897000 dcd6c3 Raising an exception!: RuntimeError
Traceback (most recent call last):
  File "/var/task/chalice/__init__.py", line 192, in __call__
    response = view_function(*function_args)
  File "/var/task/app.py", line 9, in index
    return a()
  File "/var/task/app.py", line 12, in a
    return b()
  File "/var/task/app.py", line 15, in b
    raise RuntimeError("Raising an exception!")
RuntimeError: Raising an exception!
```

Fixes aws#50.
jamesls added a commit to jamesls/chalice that referenced this issue Aug 1, 2016
Before:

```
{
    "errorMessage": "Raising an exception!",
    "errorType": "RuntimeError",
    "stackTrace": [
        [
            "/var/task/chalice/__init__.py",
            198,
            "__call__",
            "raise e"
        ]
    ]
}
```

After:
```
{
    "errorMessage": "Raising an exception!",
    "errorType": "RuntimeError",
    "stackTrace": [
        [
            "/var/task/chalice/__init__.py",
            192,
            "__call__",
            "response = view_function(*function_args)"
        ],
        [
            "/var/task/app.py",
            9,
            "index",
            "return a()"
        ],
        [
            "/var/task/app.py",
            12,
            "a",
            "return b()"
        ],
        [
            "/var/task/app.py",
            15,
            "b",
            "raise RuntimeError(\"Raising an exception!\")"
        ]
    ]
}
```

This also shows up in `chalice logs`:

```
2016-08-01 16:14:06.897000 dcd6c3 Raising an exception!: RuntimeError
Traceback (most recent call last):
  File "/var/task/chalice/__init__.py", line 192, in __call__
    response = view_function(*function_args)
  File "/var/task/app.py", line 9, in index
    return a()
  File "/var/task/app.py", line 12, in a
    return b()
  File "/var/task/app.py", line 15, in b
    raise RuntimeError("Raising an exception!")
RuntimeError: Raising an exception!
```

Fixes aws#50.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants