question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not informative exception

See original GitHub issue

Hi @wyfo ,

First of all, the project is impressive! We get a boost of 25% compared to well-tuned Pydantic serialization, which was like the following one when all non-BaseModel nested attributes were on the shoulders of orjson’s SIMD.:

def default(obj: Any) -> Any:
    if isinstance(obj, BaseModel):
        return dict(obj)
    raise TypeError

orjson.dumps(content, default=default)

I get these results on not-Cythonized version. So the main benchmark will occur shortly after integration, and I strongly believe that I’ll get superior results.

But lets’ get closer to the issue topic

from typing import Optional, List
import dataclasses
from apischema import serialize


@dataclasses.dataclass
class Item:
    name: str
    price: Optional[float] = None
    owner_ids: Optional[List[int]] = None


value = Item(name="coerce", price="1.0")
serialize(Item, value, check_type=True)

I’m getting the following exception.

Traceback (most recent call last):
  File "C:\Users\sdubr\PycharmProjects\squall\report.py", line 14, in <module>
    serialize(Item, value, check_type=True)
  File "C:\Users\sdubr\PycharmProjects\squall\venv\lib\site-packages\apischema\utils.py", line 424, in wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\sdubr\PycharmProjects\squall\venv\lib\site-packages\apischema\serialization\__init__.py", line 577, in serialize
    return serialization_method(
  File "C:\Users\sdubr\PycharmProjects\squall\venv\lib\site-packages\apischema\serialization\__init__.py", line 185, in wrapper
    return fallback(obj)
  File "C:\Users\sdubr\PycharmProjects\squall\venv\lib\site-packages\apischema\serialization\__init__.py", line 169, in method
    raise TypeError(f"Expected {tp}, found {obj.__class__}")
TypeError: Expected <class '__main__.Item'>, found <class '__main__.Item'>

The fact that exception has arrived is proper behavior that I expect. But, the exception doesn’t provide any useful information. It will be great to see something similar to exceptions we can get from the deserialization phase.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wyfocommented, Nov 27, 2021

In fact, I did not take in account complex things like SQLAlchemy in my statement about static type checking. It’s indeed an argument to consider about adding error location tracing. However, I think indeed that collecting all errors will never be done, as there would be surely too much impact on unchecked code.

I propose you to keep this issue for the bug fix only, and to create another one about the error location tracing. I think it will have to wait v0.17, because the code has been completely changed since with cythonization.

1reaction
wyfocommented, Nov 27, 2021

Actually, this bug has already been fixed in the upcoming v0.17, but I agree the exception is odd and should be fixed in v0.16. I will include the bug fix in v0.16.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not informative exception message · Issue #2569 · sphinx-doc ...
I have just stumbled across an exception whose message does not give much information: Exception occurred: File "/home/andrea/.local/lib/python3 ...
Read more >
Not informative exception [225060184] - Visible to Public - Issue ...
When SystemJobService#onCreate throw IllegalStateException it shadows exception from WorkManagerImpl#getInstance and may hide some useful information.
Read more >
Make exceptions more informative - java - Stack Overflow
Is there a way to make Java Exceptions more informative? For example, take this code from the ClassCastException docs: Object x = new...
Read more >
Python Errors, How Can You Make Python Exceptions More ...
I've collected every possible exception and I have created a handler that can take as much information as possible from the error and...
Read more >
[Solved]-Not informative exception info on xCode 4.6 - appsloveworld
Here's something I do to get the stack trace. In your AppDelegate.m file: void uncaughtExceptionHandler(NSException *exception) { NSLog(@"Call Stack: %@" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found