2
2
3
3
import java .io .PrintWriter ;
4
4
import java .io .StringWriter ;
5
+ import java .util .Objects ;
5
6
6
7
public class ExceptionUtils {
7
- /**
8
- * Formalized exception error strings
9
- */
10
- public static final String ERR_SOURCE_EXCEPTION = "UDF_EXECUTION_ERROR(source)" ;
11
- public static final String ERR_TRANSFORMER_EXCEPTION = "UDF_EXECUTION_ERROR(transformer)" ;
12
- public static final String ERR_SINK_EXCEPTION = "UDF_EXECUTION_ERROR(sink)" ;
13
- public static final String ERR_MAP_STREAM_EXCEPTION = "UDF_EXECUTION_ERROR(mapstream)" ;
14
- public static final String ERR_MAP_EXCEPTION = "UDF_EXECUTION_ERROR(map)" ;
15
- public static final String ERR_BATCH_MAP_EXCEPTION = "UDF_EXECUTION_ERROR(batchmap)" ;
16
- public static final String ERR_SERVING_STORE_EXCEPTION = "UDF_EXECUTION_ERROR(servingstore)" ;
8
+
9
+ /**
10
+ * UD Container Type Environment Variable
11
+ */
12
+ public static final String ENV_UD_CONTAINER_TYPE = "NUMAFLOW_UD_CONTAINER_TYPE" ;
13
+ public static final String CONTAINER_NAME = System .getenv (ENV_UD_CONTAINER_TYPE );
17
14
18
15
/**
19
16
* Converts the stack trace of an exception into a String.
20
17
*
21
- * @param e the exception to extract the stack trace from
18
+ * @param t the exception to extract the stack trace from
22
19
*
23
20
* @return the stack trace as a String
24
21
*/
@@ -30,4 +27,13 @@ public static String getStackTrace(Throwable t) {
30
27
t .printStackTrace (new PrintWriter (sw ));
31
28
return sw .toString ();
32
29
}
30
+
31
+ /**
32
+ * Returns a formalized exception error string.
33
+ *
34
+ * @return the formalized exception error string
35
+ */
36
+ public static String getExceptionErrorString () {
37
+ return "UDF_EXECUTION_ERROR(" + Objects .requireNonNullElse (CONTAINER_NAME , "unknown-container" ) + ")" ;
38
+ }
33
39
}
0 commit comments