It says that server can't properly test my solution
Create an exception factory class that has a single static method that returns the required exception.
This method should accept one enum argument. Do the following for each of these enums:
* ApplicationExceptionMessage: return an Exception
* DatabaseExceptionMessage: return a RuntimeException
* UserExceptionMessage: return an Error otherwise: return IllegalArgumentException without a message.
Use the name of the enum field as the message of the returned object, replacing all of the underscores with spaces. Everything must be lowercase except the first character of the message.
For example, the message for ApplicationExceptionMessage.SOCKET_IS_CLOSED should be "Socket is closed".
Return the created factory class in the Solution.getFactoryClass method.
Don't change the enums.
Requirements:
The getFactoryClass method must return the exception factory.
ApplicationExceptionMessage must not have any additional methods or constructors.
DatabaseExceptionMessage must not have any additional methods or constructors.
UserExceptionMessage must not have any additional methods or constructors.
The static exception factory method must return the exceptions listed in the conditions (including the message) for any inputs.
The factory must have one method and it must be static.
package com.codegym.task.task38.task3804;
public class Solution {
public static Class getFactoryClass() {
return null;
}
public static void main(String[] args) {
}
}
1. Look at the requirements again - It says to throw an Error if the enum is part of UserExceptionMessage, and throw an IllegalArgumentException if the enum passed is not one of the three ExceptionMessage enums provided. Also look again at the ExceptionMessage enums provided, as there seems to be more than one value in each...
2. You are on the right track with the (e == UserExceptionMessage.USER_DOES_NOT_EXIST) clause - make sure to pass the message to the constructor of every Exception/Error you create (other than the IllegalArgumentException).
3. In your Solution Class, you need to somehow return the class of the Exception factory class you created...
0
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.