Skip to content

Commit

Permalink
added new business exception
Browse files Browse the repository at this point in the history
  • Loading branch information
hazal-karakus committed Jan 9, 2025
1 parent 600b231 commit d048c4b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions react/src/components/NotEnoughInventory.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import './complete.css';
import { Link } from 'react-router-dom';

function NotEnoughInventory() {
return (
<div className="not-enough-inventory">
<h2>Not Enough Inventory</h2>
<p>
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 <Link to="/">contact us</Link>.
</p>
</div>
);
}

export default NotEnoughInventory;
2 changes: 2 additions & 0 deletions react/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -360,6 +361,7 @@ class App extends Component {
path="/products-join"
element={<ProductsJoin backend={BACKEND_URL} />}
></Route>
<Route path="/not-enough-inventory" element={<NotEnoughInventory />} />NotEnoughInventory
<Route path="*" element={<NotFound />} />
</SentryRoutes>
</div>
Expand Down
13 changes: 12 additions & 1 deletion react/src/utils/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ const rangeError = () => {
const unhandledError = () => {
throw new UnhandledException('unhandled error');
};
const inventoryError = () => {
throw new InventoryException('unhandled error');
};

const randomErrors = [
notAFunctionError,
referenceError,
syntaxError,
rangeError,
unhandledError,
inventoryError,
];

const throwErrorNumber = (i) => {
Expand Down Expand Up @@ -61,4 +65,11 @@ class UnhandledException extends Error {
}
}

export { crasher, UnhandledException };
class InventoryException extends Error {
constructor(message, functionName) {
super(message);
}
}


export { crasher, UnhandledException, InventoryException };

0 comments on commit d048c4b

Please sign in to comment.