{ "info": { "author": "Jonas Grimfelt", "author_email": "grimen@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries" ], "description": "# `mybad` [![PyPI version](https://badge.fury.io/py/mybad.svg)](https://badge.fury.io/py/mybad) [![Build Status](https://travis-ci.com/grimen/python-mybad.svg?branch=master)](https://travis-ci.com/grimen/python-mybad) [![Coverage Status](https://codecov.io/gh/grimen/python-mybad/branch/master/graph/badge.svg)](https://codecov.io/gh/grimen/python-mybad)\n\n*My friendly error base class - for Python.*\n\n## Introduction\n\nOne in general always needs a application/library specific error base class, but the native errors are very limited in what meta/debugging information they can hold at time they are raised. For better debugging and error reporting/inspection this error base class allows to attach some additonal error context information that can be used to better understand the issue - without having to create custom error formatters, or run debugger.\n\n\n## Install\n\nInstall using **pip**:\n\n```sh\n$ pip install mybad\n```\n\n\n## Use\n\nVery basic **[example](https://github.com/grimen/python-mybad/tree/master/examples/basic.py)**:\n\n```python\nfrom mybad import Error\n\nclass ToMuchError(Error):\n pass\n\ndef print_money(stash):\n try:\n if isinstance(stash, str) and len(stash) > 13:\n raise Exception('Too much money to print: {0}'.format(stash))\n\n print('PRINT {0}'.format(stash))\n\n except Exception as error:\n raise ToMuchError(error,\n message = 'Out of money printing ink...',\n id = hash(stash),\n key = 'too_much',\n code = 400,\n details = dict(\n stash = stash,\n )\n )\n\namount = ''\n\nfor dollar in range(42):\n amount += '$'\n\n print_money(amount)\n\n```\n\nRun this with optional environment variables `COLORS` / `ERROR_COLORS` and/or `VERBOSE` / `ERROR_VERBOSE` set too truthy or falsy values, so see various error info formatting in terminal.\n\nSomething like this (imagine some colorized formatting):\n\n```bash\nPRINT $\nPRINT $$\nPRINT $$$\nPRINT $$$$\nPRINT $$$$$\nPRINT $$$$$$\nPRINT $$$$$$$\nPRINT $$$$$$$$\nPRINT $$$$$$$$$\nPRINT $$$$$$$$$$\nPRINT $$$$$$$$$$$\nPRINT $$$$$$$$$$$$\nPRINT $$$$$$$$$$$$$\n===============================\n str(error)\n---------------------------\nOut of money printing ink... - {'stash': '$$$$$$$$$$$$$$'}\n\n===============================\n error.stack\n---------------------------\nTraceback (most recent call last):\n File \"examples/basic.py\", line 27, in print_money\n raise Exception('Too much money to print: {0}'.format(stash))\nException: Too much money to print: $$$$$$$$$$$$$$\n\n===============================\n error.inspect()\n---------------------------\n{ 'code': 400,\n 'details': {'stash': '$$$$$$$$$$$$$$'},\n 'id': 3563898309523127190,\n 'key': 'too_much',\n 'message': 'Out of money printing ink...',\n 'stack': [ { 'code': ['stash = stash,'],\n 'file': 'examples/basic.py',\n 'function': 'print_money',\n 'line': 38},\n { 'code': ['print_money(amount)'],\n 'file': 'examples/basic.py',\n 'function': '',\n 'line': 48}],\n 'type': 'ToMuchError'}\n\n\n===============================\n error.json()\n---------------------------\n{\n \"type\": \"ToMuchError\",\n \"id\": 3563898309523127190,\n \"code\": 400,\n \"key\": \"too_much\",\n \"message\": \"Out of money printing ink...\",\n \"details\": {\n \"stash\": \"$$$$$$$$$$$$$$\"\n },\n \"stack\": [\n {\n \"file\": \"examples/basic.py\",\n \"function\": \"print_money\",\n \"line\": 38,\n \"code\": [\n \"stash = stash,\"\n ]\n },\n {\n \"file\": \"examples/basic.py\",\n \"function\": \"\",\n \"line\": 48,\n \"code\": [\n \"print_money(amount)\"\n ]\n }\n ]\n}\n\n```\n\n\n## Test\n\nClone down source code:\n\n```sh\n$ make install\n```\n\nRun **colorful tests**, with only native environment (dependency sandboxing up to you):\n\n```sh\n$ make test\n```\n\nRun **less colorful tests**, with **multi-environment** (using **tox**):\n\n```sh\n$ make test-tox\n```\n\n\n## Related\n\n- [**`mybase`**](https://github.com/grimen/python-mybase) - *\"My friendly library base class - for Python\"*\n\n\n## About\n\nThis project was mainly initiated - in lack of solid existing alternatives - to be used at our work at **[Markable.ai](https://markable.ai)** to have common code conventions between various programming environments where **Python** (research, CV, AI) is heavily used.\n\n\n## License\n\nReleased under the MIT license.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/grimen/python-mybad", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/grimen/python-mybad", "keywords": "error,errors,baseclass,meta,debug,inspector,pretty,color,colors,detailed,stacktrace", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mybad", "package_url": "https://pypi.org/project/mybad/", "platform": "", "project_url": "https://pypi.org/project/mybad/", "project_urls": { "Download": "https://github.com/grimen/python-mybad", "Homepage": "https://github.com/grimen/python-mybad", "bugs": "https://github.com/grimen/python-mybad/issues", "repository": "https://github.com/grimen/python-mybad" }, "release_url": "https://pypi.org/project/mybad/0.2.0/", "requires_dist": [ "setupextras (>=0.1.5)", "six (>=1.12.0)", "rootpath (>=0.1.1)", "inspecta (>=0.1.3)", "attributedict (>=0.3.0)", "termcolor (>=1.1.0)", "colour-runner (>=0.0.5)", "deepdiff (>=3.3.0)", "tox (>=3.0.0)", "coverage (>=4.5.2)", "codecov (>=2.0.15)" ], "requires_python": "", "summary": "My friendly error base class - for Python.", "version": "0.2.0" }, "last_serial": 5254149, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "502c7d03e8d1138641d577b7e9e25996", "sha256": "e830ba894ea029f877263a5178b653f85f0facf73b3c0854a0e6a47d428732ea" }, "downloads": -1, "filename": "mybad-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "502c7d03e8d1138641d577b7e9e25996", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8473, "upload_time": "2019-01-27T08:31:18", "url": "https://files.pythonhosted.org/packages/d4/19/da65e0b1c5362abd4143dbe69edaac7103ee09ff4fe37928697b3463375e/mybad-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "df244e0dd61c8ab0d8fd8e23388a61d2", "sha256": "59eb3a2527932b49720804d09522c6a20834ee2808f6f9bce2f34d86aebd76ee" }, "downloads": -1, "filename": "mybad-0.1.0.tar.gz", "has_sig": false, "md5_digest": "df244e0dd61c8ab0d8fd8e23388a61d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11517, "upload_time": "2019-01-27T08:31:20", "url": "https://files.pythonhosted.org/packages/7c/8a/4c841259ec70f02d530940a88c4ad5947c933f21a0ca912ec2e2c084f2cf/mybad-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1bb436f0e67b8474929e8259bce477a1", "sha256": "6bf663433db440219c3611b1dce88a8ca585dbe8bc7d37c9330fb8cde0dce914" }, "downloads": -1, "filename": "mybad-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1bb436f0e67b8474929e8259bce477a1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8126, "upload_time": "2019-01-28T05:28:20", "url": "https://files.pythonhosted.org/packages/b4/da/f27257b44885b5cf43aa6166ec2560efc49c7a5e71f18a0270cfcc3222cd/mybad-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7a6c4ed592851bf59bf5f7c3f0f4da8f", "sha256": "989f34d737a434f084d557a9df10cdee317c90519c07cca6f67b89a3bd08d60d" }, "downloads": -1, "filename": "mybad-0.1.1.tar.gz", "has_sig": false, "md5_digest": "7a6c4ed592851bf59bf5f7c3f0f4da8f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11259, "upload_time": "2019-01-28T05:28:21", "url": "https://files.pythonhosted.org/packages/74/d6/309e942caefa4fb036c5796345ea4cd75f170ca46983c0c4a5e2d70bd589/mybad-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "c119e619e9895f69e6d779760416e2fe", "sha256": "0fc5ead3998b25ddd51d4d8c6510ece20781047662a0ac59e6d96ef095003e5e" }, "downloads": -1, "filename": "mybad-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c119e619e9895f69e6d779760416e2fe", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10277, "upload_time": "2019-01-28T05:38:14", "url": "https://files.pythonhosted.org/packages/96/ac/3050ad0e02880df7dda8c111a46e09c220e3798dbfa10cf24305092d0378/mybad-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9325d56e9c2ad25a82fe80e55d0d8206", "sha256": "144262b039e015a8ca708c030c478b648c767df558ef2d1177f3c18501feef04" }, "downloads": -1, "filename": "mybad-0.1.2.tar.gz", "has_sig": false, "md5_digest": "9325d56e9c2ad25a82fe80e55d0d8206", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11242, "upload_time": "2019-01-28T05:38:16", "url": "https://files.pythonhosted.org/packages/32/bb/e3a3597e85d076ae508ccddb0aad679a1575e7dd80e4f1c79091f694d091/mybad-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "66a0d8d614e7870205f4d17707c9d3b2", "sha256": "f1570e6849b4be2f2ecc576af0b392ee84ceb8248c715d017bd160a8894189db" }, "downloads": -1, "filename": "mybad-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "66a0d8d614e7870205f4d17707c9d3b2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10369, "upload_time": "2019-03-10T11:15:14", "url": "https://files.pythonhosted.org/packages/7f/a6/90a133d5b3d54754ede82ca73f6cf1d9f9afc74c117855f815d76eae2f59/mybad-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c47c9eca50af12661810ce70f3249b90", "sha256": "618dba0bbc02c1cd99e23bc49caaaa0bd14d5ef92ebfcbfcf0e29a88e068a896" }, "downloads": -1, "filename": "mybad-0.1.3.tar.gz", "has_sig": false, "md5_digest": "c47c9eca50af12661810ce70f3249b90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11555, "upload_time": "2019-03-10T11:15:15", "url": "https://files.pythonhosted.org/packages/69/c2/fbc63b57d26d42769a2946e133099a3e57e03b9eeca025cb00a96d0afc26/mybad-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "4502692d53f84a537895e7f97804eaf9", "sha256": "80624dfb48ba7f34618fb0b87c605e717b4e529f5673985561713c54b9c38f51" }, "downloads": -1, "filename": "mybad-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "4502692d53f84a537895e7f97804eaf9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10432, "upload_time": "2019-03-31T07:54:56", "url": "https://files.pythonhosted.org/packages/f8/d8/9c08c04f0f1806b386f2b2427d43089c70e2b8f5b5b816004ab20260b37b/mybad-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "50bab6028e2da06ba2897cc94dc05696", "sha256": "46e4e7d3f40cf66416285d9c89aeb145c57bacbed224fa1c31ae76278f5356f0" }, "downloads": -1, "filename": "mybad-0.1.4.tar.gz", "has_sig": false, "md5_digest": "50bab6028e2da06ba2897cc94dc05696", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11653, "upload_time": "2019-03-31T07:54:57", "url": "https://files.pythonhosted.org/packages/45/fb/5e437c2a05a8fc5b15293519a443bcc4d8370ce0d4c79a0101654a048613/mybad-0.1.4.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "83037b1fec6d987453f4bbe660bbd0aa", "sha256": "d2c8f1f9e0f9b687ab5a46689e5928314bc53ede8122611ef36442ca4c8a1bf8" }, "downloads": -1, "filename": "mybad-0.2.0-py2-none-any.whl", "has_sig": false, "md5_digest": "83037b1fec6d987453f4bbe660bbd0aa", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 13695, "upload_time": "2019-05-10T21:18:11", "url": "https://files.pythonhosted.org/packages/f0/91/8267d5ba58fd4486e4c6af1ce94f15b6b0aa2988386e1067e21f8cf12c4e/mybad-0.2.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e57758dc33d5018a94d2657a2321b93", "sha256": "b49b155adabceb2659dbb0bfd3420671dee5febe10bf5e8d499d750d34f75616" }, "downloads": -1, "filename": "mybad-0.2.0.tar.gz", "has_sig": false, "md5_digest": "3e57758dc33d5018a94d2657a2321b93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13433, "upload_time": "2019-05-10T21:18:13", "url": "https://files.pythonhosted.org/packages/fb/62/5366bda200b009452f4446ade7758f0a18be21a3131ca5e541d4b07e6d4e/mybad-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "83037b1fec6d987453f4bbe660bbd0aa", "sha256": "d2c8f1f9e0f9b687ab5a46689e5928314bc53ede8122611ef36442ca4c8a1bf8" }, "downloads": -1, "filename": "mybad-0.2.0-py2-none-any.whl", "has_sig": false, "md5_digest": "83037b1fec6d987453f4bbe660bbd0aa", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 13695, "upload_time": "2019-05-10T21:18:11", "url": "https://files.pythonhosted.org/packages/f0/91/8267d5ba58fd4486e4c6af1ce94f15b6b0aa2988386e1067e21f8cf12c4e/mybad-0.2.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3e57758dc33d5018a94d2657a2321b93", "sha256": "b49b155adabceb2659dbb0bfd3420671dee5febe10bf5e8d499d750d34f75616" }, "downloads": -1, "filename": "mybad-0.2.0.tar.gz", "has_sig": false, "md5_digest": "3e57758dc33d5018a94d2657a2321b93", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13433, "upload_time": "2019-05-10T21:18:13", "url": "https://files.pythonhosted.org/packages/fb/62/5366bda200b009452f4446ade7758f0a18be21a3131ca5e541d4b07e6d4e/mybad-0.2.0.tar.gz" } ] }