]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/yapf/yapflib/errors.py
1 # Copyright 2015 Google Inc. All Rights Reserved.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """YAPF error objects."""
16 from yapf_third_party
._ylib
2to
3.pgen2
import tokenize
19 def FormatErrorMsg(e
):
20 """Convert an exception into a standard format.
22 The standard error message format is:
24 <filename>:<lineno>:<column>: <msg>
30 A properly formatted error message string.
32 if isinstance(e
, SyntaxError):
33 return '{}:{}:{}: {}'.format(e
.filename
, e
.lineno
, e
.offset
, e
.msg
)
34 if isinstance(e
, tokenize
.TokenError
):
35 return '{}:{}:{}: {}'.format(e
.filename
, e
.args
[1][0], e
.args
[1][1],
37 return '{}:{}:{}: {}'.format(e
.args
[1][0], e
.args
[1][1], e
.args
[1][2], e
.msg
)
40 class YapfError(Exception):
41 """Parent class for user errors or input errors.
43 Exceptions of this type are handled by the command line tool
44 and result in clear error messages, as opposed to backtraces.