1 /*
2  * Copyright (C) 2019, HuntLabs
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 module hunt.database.driver.postgresql.impl.codec.ErrorResponse;
19 
20 import hunt.database.driver.postgresql.impl.codec.Response;
21 
22 import hunt.database.driver.postgresql.PostgreSQLException;
23 
24 /**
25  * @author <a href="mailto:emad.albloushi@gmail.com">Emad Alblueshi</a>
26  */
27 
28 class ErrorResponse : Response {
29 
30     PgException toException() {
31         return new PgException(getMessage(), getSeverity(), getCode(), getDetail());
32     }
33 
34     override
35     string toString() {
36         return "ErrorResponse{" ~
37             "severity='" ~ getSeverity() ~ "\'" ~ 
38             ", code='" ~ getCode() ~ "\'" ~ 
39             ", message='" ~ getMessage() ~ "\'" ~ 
40             ", detail='" ~ getDetail() ~ "\'" ~ 
41             ", hint='" ~ getHint() ~ "\'" ~ 
42             ", position='" ~ getPosition() ~ "\'" ~ 
43             ", internalPosition='" ~ getInternalPosition() ~ "\'" ~ 
44             ", internalQuery='" ~ getInternalQuery() ~ "\'" ~ 
45             ", where='" ~ getWhere() ~ "\'" ~ 
46             ", file='" ~ getFile() ~ "\'" ~ 
47             ", line='" ~ getLine() ~ "\'" ~ 
48             ", routine='" ~ getRoutine() ~ "\'" ~ 
49             ", schema='" ~ getSchema() ~ "\'" ~ 
50             ", table='" ~ getTable() ~ "\'" ~ 
51             ", column='" ~ getColumn() ~ "\'" ~ 
52             ", dataType='" ~ getDataType() ~ "\'" ~ 
53             ", constraint='" ~ getConstraint() ~ "\'" ~ 
54             '}';
55     }
56 }