Skip to content

Commit

Permalink
👌 Update to match newest requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPradat committed Feb 25, 2021
1 parent 6d7fbc3 commit 3f2fda7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
2 changes: 2 additions & 0 deletions exercises/concept/errors/.docs/hints.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Hints

## 1. Monitor the humidity level of the room

- You might want to use an [if...else condition][if-else-condition] to check if the humidity percentage is higher than the maximum allowed value.
Expand Down
12 changes: 7 additions & 5 deletions exercises/concept/errors/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Instructions

Elena is the new quality manager of a newspaper factory. As she has just arrived in the company, she has decided to review some of the processes in the factory to see what could be improved. She found out that technicians are doing a lot of quality checks by hand. She sees there is a good oportunity for automation and asks you, a freelance developer, to develop a piece of software to monitor some of the machines.

## Check the humidity level of the production room
Expand Down Expand Up @@ -37,12 +39,12 @@ Implements a function `checkHumidityLevel` that takes the humidity percentage as
You should throw an error (the message isn't important) if the percentage exceeds 70%.

```javascript
checkHumidityLevel(60)
checkHumidityLevel(60);
// Returns undefined
```

```javascript
checkHumidityLevel(100)
checkHumidityLevel(100);
// Throws an error
```

Expand All @@ -55,12 +57,12 @@ If the sensor is broken, the temperature will be null. In this case you should t
When everything works, if the temperature exceeds 500°C, you should throw a `OverheatingError`. This error class will be instanciated with a temperature argument. Make sure that the `OverheatingError` you throw has a temperature property attached to it.

```javascript
reportOverheating(null)
reportOverheating(null);
// Throws an ArgumentError
```

```javascript
reportOverheating(800)
reportOverheating(800);
// Throws an OverheatingError
```

Expand Down Expand Up @@ -91,5 +93,5 @@ monitorTheMachine({
alertDeadSensor,
alertOverheating,
shutdown,
})
});
```
14 changes: 8 additions & 6 deletions exercises/concept/errors/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# Introduction

Errors are useful to report when something is wrong or unexpected in a program or a piece of code.

They are javascript objects.

The main property of this object is `message`:

```javascript
const error = new Error('Oops, something went wrong')
const error = new Error('Oops, something went wrong');

console.log(error.message)
console.log(error.message);
// => "Oops, something went wrong"
```

Using the `throw` syntax, you can throw an Error.

```javascript
throw new Error('Oops')
throw new Error('Oops');
```

When an Error is thrown, the current execution is stopped and resume in the first catch block of the call stack.

```javascript
try {
throw new Error('Oops')
throw new Error('Oops');
} catch (error) {
console.log(error.message)
console.log(error.message);
// => "Oops"
}
```
Expand All @@ -37,7 +39,7 @@ try {
// ... Code that may throw an error
} catch (error) {
if (error instanceof CustomError) {
console.log('The error thrown is an instance of the CustomError')
console.log('The error thrown is an instance of the CustomError');
}
}
```
10 changes: 6 additions & 4 deletions exercises/concept/errors/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"exercism_username": "TomPradat"
}
],
"editor": {
"solution_files": ["errors.js"],
"test_files": ["errors.spec.js"]
}
"files": {
"solution": ["errors.js"],
"test": ["errors.spec.js"],
"exemplar": [".meta/example.js"]
},
"blurb": "Learn how to handle errors by creating a piece of software for a newspaper factory."
}
2 changes: 2 additions & 0 deletions exercises/concept/errors/.meta/design.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Design

## Goal

The goal of this exercise is to teach the student how to handle errors / exception, throw them and create their own.
Expand Down
File renamed without changes.

0 comments on commit 3f2fda7

Please sign in to comment.