Package com.powsybl.computation
Class ComputationExceptionBuilder
java.lang.Object
com.powsybl.computation.ComputationExceptionBuilder
Used to ease the creation of a
ComputationException
.
The builder provides methods to register logs and files from different sources.- Author:
- Yichen TANG <yichen.tang at rte-france.com>, Sylvain LECLERC <sylvain.leclerc at rte-france.com>
-
Constructor Summary
ConstructorDescriptionInitializes the builder, with no cause, no message and no logs.Initializes the builder with the specified exception as the computation exception cause. -
Method Summary
Modifier and TypeMethodDescriptionAdds raw content of a file to collected data.Adds an error log to collected data.addErrLogIfExists
(Path path) Reads the content of standard error file at specified path, assuming UTF-8 encoding.addFileIfExists
(Path path) Adds the content of a the file at specified path to collected data.Adds a standard output log to collected data.addOutLogIfExists
(Path path) Reads the content of standard output file at specified path, assuming UTF-8 encoding.build()
Creates the computation exception.Defines the detail message of the created computation exception.
-
Constructor Details
-
ComputationExceptionBuilder
public ComputationExceptionBuilder()Initializes the builder, with no cause, no message and no logs. -
ComputationExceptionBuilder
Initializes the builder with the specified exception as the computation exception cause.
-
-
Method Details
-
message
Defines the detail message of the created computation exception.- Parameters:
message
- the detail message of the computation exception.- Returns:
- this
-
addOutLogIfExists
Reads the content of standard output file at specified path, assuming UTF-8 encoding. This log will be associated to the file name. If path isnull
or file does not exist, this is a no-op.- Parameters:
path
- The path to the standard output file.- Returns:
- this
-
addOutLog
Adds a standard output log to collected data.- Parameters:
logName
- the log name, must not benull
log
- log content, may benull
- Returns:
- this
-
addErrLogIfExists
Reads the content of standard error file at specified path, assuming UTF-8 encoding. This log will be associated to the file name. If path isnull
or file does not exist, this is a no-op.- Parameters:
path
- The path to the standard error file.- Returns:
- this
-
addErrLog
Adds an error log to collected data.- Parameters:
logName
- the log name, must not benull
log
- log content, may benull
- Returns:
- this
-
addFileIfExists
Adds the content of a the file at specified path to collected data. It will be associated to the file name. If path isnull
or file does not exist, this is a no-op.- Parameters:
path
- to the file to be added to collected data.- Returns:
- this
-
addBytes
Adds raw content of a file to collected data.- Parameters:
key
- The log file name.bytes
- Bytes.- Returns:
- this
-
build
Creates the computation exception.- Returns:
- the created computation exception.
-