generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add handling for larger Float and Decimal numbers * add tracing details to the error response * handle invalid data type * add data type check parsing
- Loading branch information
Showing
25 changed files
with
690 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...stgres-server/src/main/java/org/finos/legend/engine/postgres/PostgresServerException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2023 Goldman Sachs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package org.finos.legend.engine.postgres; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.propagation.TextMapSetter; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import org.finos.legend.engine.postgres.utils.OpenTelemetryUtil; | ||
|
||
public class PostgresServerException extends RuntimeException | ||
{ | ||
private static final TextMapSetter<Map> TEXT_MAP_SETTER = (map, key, value) -> Objects.requireNonNull(map).put(key, value); | ||
|
||
private Map<String, String> tracingDetails = new HashMap<>(); | ||
|
||
public PostgresServerException(Throwable cause) | ||
{ | ||
super(cause); | ||
addTracingDetails(); | ||
} | ||
|
||
public PostgresServerException(String message) | ||
{ | ||
super(message); | ||
addTracingDetails(); | ||
} | ||
|
||
public PostgresServerException(String message, Throwable cause) | ||
{ | ||
super(message, cause); | ||
addTracingDetails(); | ||
} | ||
|
||
public static PostgresServerException wrapException(Throwable e) | ||
{ | ||
if (!(e instanceof PostgresServerException)) | ||
{ | ||
return new PostgresServerException(e); | ||
} | ||
return (PostgresServerException) e; | ||
|
||
} | ||
|
||
private void addTracingDetails() | ||
{ | ||
OpenTelemetryUtil.getPropagators().inject(Context.current(), tracingDetails, TEXT_MAP_SETTER); | ||
} | ||
|
||
public Map<String, String> getTracingDetails() | ||
{ | ||
return Collections.unmodifiableMap(tracingDetails); | ||
} | ||
} |
Oops, something went wrong.