Skip to content

exception is too much verbose #68

@belforte

Description

@belforte

I am using py3-dbs3-client/4.0.7 on python 3.8
I find that exception message from DBS error is way too much verbose to be usable/useful in logs.
Can something be done ?

Here's a quick example where I try to access a non-existing API [1].
Applications using DBS Client do not care to know the internal traceback (note in particular the During handling of the above exception, another exception occurred: In this case these two lines
would have been plenty.

RestClient.ErrorHandling.RestClientExceptions.HTTPError: HTTP Error 404: 
URL=https://cmsweb.cern.ch:8443/dbs/prod/global/BAD/serverinfo

[1]

>>> import dbs.apis.dbsClient
>>> dbs.apis.dbsClient.__file__
'/data/srv/TaskManager/v3.220314patch1-3391c4ccadfae468fd63c78475580c2d/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.7/lib/python3.8/site-packages/dbs/apis/dbsClient.py'
>>> import sys
>>> sys.version
'3.8.2 (default, Jan 22 2021, 17:57:37) \n[GCC 6.3.0]'
>>> badApi = DbsApi(url='https://cmsweb.cern.ch/dbs/prod/global/BAD')
>>> badApi.serverinfo()
Traceback (most recent call last):
  File "/data/srv/TaskManager/v3.220314patch1-3391c4ccadfae468fd63c78475580c2d/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.7/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 445, in __callServer
    self.http_response = method_func(self.url, method, params, data, request_headers)
  File "/data/srv/TaskManager/v3.220314patch1-3391c4ccadfae468fd63c78475580c2d/slc7_amd64_gcc630/cms/py3-dbs3-pycurl/3.17.7-comp/lib/python3.8/site-packages/RestClient/RestApi.py", line 36, in get
    return http_request(self._curl)
  File "/data/srv/TaskManager/v3.220314patch1-3391c4ccadfae468fd63c78475580c2d/slc7_amd64_gcc630/cms/py3-dbs3-pycurl/3.17.7-comp/lib/python3.8/site-packages/RestClient/RequestHandling/HTTPRequest.py", line 62, in __call__
    raise HTTPError(effective_url, http_code, http_response.msg, http_response.raw_header, http_response.body)
RestClient.ErrorHandling.RestClientExceptions.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/srv/TaskManager/v3.220314patch1-3391c4ccadfae468fd63c78475580c2d/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.7/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 1838, in serverinfo
    return self.__callServer("serverinfo")
  File "/data/srv/TaskManager/v3.220314patch1-3391c4ccadfae468fd63c78475580c2d/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.7/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 457, in __callServer
    self.__parseForException(data)
  File "/data/srv/TaskManager/v3.220314patch1-3391c4ccadfae468fd63c78475580c2d/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.7/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 483, in __parseForException
    raise http_error
RestClient.ErrorHandling.RestClientExceptions.HTTPError: HTTP Error 404: 
URL=https://cmsweb.cern.ch:8443/dbs/prod/global/BAD/serverinfo
Code=404
Message=Not Found
Header=HTTP/1.1 404 Not Found
Date: Fri, 18 Mar 2022 13:57:40 GMT
Server: Apache
Content-Type: text/html
Content-Length: 146
CMS-Server-Time: D=11556 t=1647611860253268


Body=<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions