package com.mns.intl.pigw.partner.sales.exception;import org.slf4j.Logger;import…
- User
package com.mns.intl.pigw.partner.sales.exception;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.slf4j.MDC;public class JSONGenerationFailure extends Exception{ private static final long serialVersionUID = 1L; private static final String EXCEPTION_CODE = "PIGW-PARTNER-JSON-GENERATION-FAILED-ER006"; private static final String ERROR_DESCRITPION = "JSON GENERATOR FAILED"; private final transient Logger logger = LoggerFactory.getLogger(this.getClass()); public JSONGenerationFailure() { super(ERROR_DESCRITPION); } public JSONGenerationFailure(Throwable cause) { super(cause); } public String getExceptionCode() { return EXCEPTION_CODE; } public String getErrorDescription() { return ERROR_DESCRITPION; } public String getErrorMessage() { return EXCEPTION_CODE + " : " + ERROR_DESCRITPION + " : " + getMessage(); } public void logErrorMessage() { MDC.put("exceptionCode", getExceptionCode()); MDC.put("errorMessage", getErrorMessage()); logger.error("JSONGENRATORFailureException", this); MDC.clear(); }}.................this is sample1............update tbelow like sample1...............FileNotParsedException.java
package com.mns.intl.pigw.partner.sales.exception;
public class FileNotParsedException extends Exception { public FileNotParsedException(String message) { super(message); }
codepublic FileNotParsedException(String message, Throwable cause) { super(message, cause); }}
- Assistant
To update the
FileNotParsedExceptionclass based on the structure and style of theJSONGenerationFailureclass you provided, we will incorporate logging capabilities, a static error code, and a detailed message generation method. After making these updates, the modified class will look like this: - User
TimeoutException.java
package com.mns.intl.pigw.partner.sales.exception;
public class TimeoutException extends Exception { public TimeoutException(String message) { super(message); }
codepublic TimeoutException(String message, Throwable cause) { super(message, cause); }}...update this also like sample1
- Assistant
Sure! Similar to your previous classes, we can update the
TimeoutExceptionclass to include error codes, descriptions, logging functionality, and conform to the structure of theJSONGenerationFailureclass. Here’s how the updatedTimeoutExceptionclass will look: - User
FileNotFoundException.java
package com.mns.intl.pigw.partner.sales.exception;
public class MyFileNotFoundException extends Exception { public MyFileNotFoundException(String message) { super(message); }
codepublic MyFileNotFoundException(String message, Throwable cause) { super(message, cause); }}.....update this like sample1
- Assistant
Certainly! We'll update the
MyFileNotFoundExceptionclass to include an exception code, error description, logging functionality, and align its structure with the previous examples you've provided. Here is the updated code:java - User
instead of MyFile...change to something else
- Assistant
Sure! Let's rename
MyFileNotFoundExceptionto a more conventional name, such asCustomFileNotFoundException. Here’s the updated code:java