diff --git a/react/src/components/NotEnoughInventory.jsx b/react/src/components/NotEnoughInventory.jsx
new file mode 100644
index 000000000..0e18dea93
--- /dev/null
+++ b/react/src/components/NotEnoughInventory.jsx
@@ -0,0 +1,16 @@
+import './complete.css';
+import { Link } from 'react-router-dom';
+
+function NotEnoughInventory() {
+ return (
+
+
Not Enough Inventory
+
+ The product you are interested is out of stock.Please accept our deepest
+ apologies. If you want to know when it will be available, please contact us.
+
+
+ );
+}
+
+export default NotEnoughInventory;
diff --git a/react/src/index.js b/react/src/index.js
index 1cba33010..d6aee1dc3 100644
--- a/react/src/index.js
+++ b/react/src/index.js
@@ -35,6 +35,7 @@ import CompleteError from './components/CompleteError';
import Employee from './components/Employee';
import Home from './components/Home';
import NotFound from './components/NotFound';
+import NotEnoughInventory from './components/NotEnoughInventory';
import Product from './components/Product';
import Products from './components/Products';
import ProductsJoin from './components/ProductsJoin';
@@ -360,6 +361,7 @@ class App extends Component {
path="/products-join"
element={}
>
+ } />NotEnoughInventory
} />
diff --git a/react/src/tests/Errors.test.js b/react/src/tests/Errors.test.js
index e0b15326c..2a9a141f2 100644
--- a/react/src/tests/Errors.test.js
+++ b/react/src/tests/Errors.test.js
@@ -1,4 +1,4 @@
-import { crasher, UnhandledException } from '../utils/errors';
+import { crasher, UnhandledException, InventoryException } from '../utils/errors';
import { createBrowserHistory } from 'history';
describe('Errors module', () => {
@@ -40,11 +40,21 @@ describe('Errors module', () => {
expect(() => crasher()).toThrow(RangeError);
});
- test('should throw an UnhandledException when "crash" is true and errnum is 4', () => {
+ test('should throw a RangeError when "crash" is true and errnum is 4', () => {
setQueryParams({ crash: 'true', errnum: '4' });
+ expect(() => crasher()).toThrow(RangeError);
+ });
+
+ test('should throw an UnhandledException when "crash" is true and errnum is 5', () => {
+ setQueryParams({ crash: 'true', errnum: '5' });
expect(() => crasher()).toThrow(UnhandledException);
});
+ test('should throw an InventoryException when "crash" is true and errnum is 6', () => {
+ setQueryParams({ crash: 'true', errnum: '6' });
+ expect(() => crasher()).toThrow(InventoryException);
+ });
+
// This test is failing, need to look into this later
// test('should log the queryParam if empty', () => {
// setQueryParams({});
diff --git a/react/src/utils/errors.js b/react/src/utils/errors.js
index 73182599a..ebcc91fe2 100644
--- a/react/src/utils/errors.js
+++ b/react/src/utils/errors.js
@@ -14,16 +14,24 @@ const syntaxError = () => eval('foo bar');
const rangeError = () => {
throw new RangeError('Parameter must be between 1 and 100');
};
+const smallRangeError = () => {
+ throw new RangeError('Parameter must be between 1 and 10');
+};
const unhandledError = () => {
throw new UnhandledException('unhandled error');
};
+const inventoryError = () => {
+ throw new InventoryException('unhandled error');
+};
const randomErrors = [
notAFunctionError,
referenceError,
syntaxError,
rangeError,
+ smallRangeError,
unhandledError,
+ inventoryError,
];
const throwErrorNumber = (i) => {
@@ -61,4 +69,11 @@ class UnhandledException extends Error {
}
}
-export { crasher, UnhandledException };
+class InventoryException extends Error {
+ constructor(message, functionName) {
+ super(message);
+ }
+}
+
+
+export { crasher, UnhandledException, InventoryException };