Skip to content

Commit

Permalink
docs: add exceptions' API docs generated by TypeDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
rainx committed Sep 23, 2023
1 parent 98a64d7 commit 8ef4bc8
Show file tree
Hide file tree
Showing 39 changed files with 2,343 additions and 89 deletions.
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# We need to ignore this cause this is auto-generated file
pnpm-lock.yaml

# skip for all auto-enerated docs
docs
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"url": "[email protected]:app/libraries.git"
},
"scripts": {
"docs": "pnpm -r --filter=./packages/** docs",
"preinstall": "npx only-allow pnpm",
"prepare": "husky install",
"build": "pnpm run clean && pnpm -r --filter=./packages/** run build",
Expand Down Expand Up @@ -42,18 +43,18 @@
"@commitlint/config-conventional": "17.7.0",
"@commitlint/cz-commitlint": "17.7.1",
"@rightcapital/exceptions": "workspace:*",
"@rightcapital/prettier-config": "6.0.1",
"@types/jest": "29.5.5",
"beachball": "2.37.0",
"@rightcapital/prettier-config": "^6.0.1",
"@types/jest": "29.5.4",
"beachball": "2.36.0",
"commitizen": "4.3.0",
"concurrently": "8.2.1",
"eslint": "8.50.0",
"eslint": "8.47.0",
"husky": "8.0.3",
"inquirer": "9.2.11",
"jest": "29.7.0",
"prettier": "3.0.3",
"inquirer": "9.2.10",
"jest": "29.6.3",
"prettier": "3.0.2",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "5.2.2"
"typescript": "5.1.6"
}
}
28 changes: 19 additions & 9 deletions packages/exceptions/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# `exceptions`

## Introduction

This library provides a set of standard Exceptions

It is inspired by the [PHP's SPL exceptions](https://www.php.net/manual/en/spl.exceptions.php)

## Installation

```bash
Expand All @@ -9,20 +15,24 @@ pnpm add @right/exceptions
## Usage

```typescript
import { RuntimeException } from '@right/exceptions';
import { RuntimeException, LogicException } from '@rightcapital/exceptions';

throw new RuntimeException('Crash!');
const logicException = new LogicException('A logic exception');

try {
// Something
} catch (e: Exception) {
if (e instanceof RuntimeException) {
throw new RuntimeException('Crash!', logicException);
} catch (exception) {
if (exception instanceof RuntimeException) {
//.... BlaBlaBla
}

// or ....
if (e.name === 'RuntimeException') {
// ....BlaBlaBla...
if (exception.isCausedBy(logicException)) {
console.log(
'Catch you!',
exception.name,
', You are caused by',
exception.cause.name,
);
}
}
}
```
1 change: 1 addition & 0 deletions packages/exceptions/docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
40 changes: 40 additions & 0 deletions packages/exceptions/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@rightcapital/exceptions / [Exports](modules.md)

# `exceptions`

## Introduction

This library provides a set of standard Exceptions

It is inspired by the [PHP's SPL exceptions](https://www.php.net/manual/en/spl.exceptions.php)

## Installation

```bash
pnpm add @right/exceptions
```

## Usage

```typescript
import { RuntimeException, LogicException } from '@rightcapital/exceptions';

const logicException = new LogicException('A logic exception');

try {
// Something
throw new RuntimeException('Crash!', logicException);
} catch (exception) {
if (exception instanceof RuntimeException) {
//.... BlaBlaBla
if (exception.isCausedBy(logicException)) {
console.log(
'Catch you!',
exception.name,
', You are caused by',
exception.cause.name,
);
}
}
}
```
137 changes: 137 additions & 0 deletions packages/exceptions/docs/classes/BadFunctionCallException.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
[@rightcapital/exceptions](../README.md) / [Exports](../modules.md) / BadFunctionCallException

# Class: BadFunctionCallException

Exception thrown if a callback refers to an undefined function or if some arguments are missing.

## Hierarchy

- [`LogicException`](LogicException.md)

**`BadFunctionCallException`**

↳↳ [`BadMethodCallException`](BadMethodCallException.md)

## Table of contents

### Constructors

- [constructor](BadFunctionCallException.md#constructor)

### Properties

- [cause](BadFunctionCallException.md#cause)
- [message](BadFunctionCallException.md#message)
- [name](BadFunctionCallException.md#name)
- [stack](BadFunctionCallException.md#stack)

### Methods

- [isCausedBy](BadFunctionCallException.md#iscausedby)

## Constructors

### constructor

**new BadFunctionCallException**(`message`, `cause?`)

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `message` | `string` | A human-readable description of the error. |
| `cause?` | `any` | The value of cause can be of any type. You should not make assumptions that the error you caught has an Error as its cause, in the same way that you cannot be sure the variable bound in the catch statement is an Error either. The "Providing structured data as the error cause" example below shows a case where a non-error is deliberately provided as the cause. |

#### Inherited from

[LogicException](LogicException.md).[constructor](LogicException.md#constructor)

#### Defined in

[packages/exceptions/src/exceptions/base.exception.ts:14](https://github.com/RightCapitalHQ/frontend-libraries/blob/98a64d7/packages/exceptions/src/exceptions/base.exception.ts#L14)

## Properties

### cause

`Optional` **cause**: `any`

The value of cause can be of any type. You should not make assumptions that the error you caught has an Error as its cause, in the same way that you cannot be sure the variable bound in the catch statement is an Error either. The "Providing structured data as the error cause" example below shows a case where a non-error is deliberately provided as the cause.

#### Inherited from

[LogicException](LogicException.md).[cause](LogicException.md#cause)

#### Defined in

[packages/exceptions/src/exceptions/base.exception.ts:16](https://github.com/RightCapitalHQ/frontend-libraries/blob/98a64d7/packages/exceptions/src/exceptions/base.exception.ts#L16)

___

### message

**message**: `string`

#### Inherited from

[LogicException](LogicException.md).[message](LogicException.md#message)

#### Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es5.d.ts:1068

___

### name

**name**: `string` = `'BadFunctionCallException'`

#### Overrides

[LogicException](LogicException.md).[name](LogicException.md#name)

#### Defined in

[packages/exceptions/src/exceptions/bad-function-call.exception.ts:8](https://github.com/RightCapitalHQ/frontend-libraries/blob/98a64d7/packages/exceptions/src/exceptions/bad-function-call.exception.ts#L8)

___

### stack

`Optional` **stack**: `string`

#### Inherited from

[LogicException](LogicException.md).[stack](LogicException.md#stack)

#### Defined in

node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.es5.d.ts:1069

## Methods

### isCausedBy

**isCausedBy**(`cause`): `boolean`

If the Error is caused by the cause we passed in the construction method

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `cause` | `any` | the cause we assume that cause the current exception |

#### Returns

`boolean`

true if the cause we passed is the original cause when the Exception constructed. otherwise, it returns false

#### Inherited from

[LogicException](LogicException.md).[isCausedBy](LogicException.md#iscausedby)

#### Defined in

[packages/exceptions/src/exceptions/base.exception.ts:27](https://github.com/RightCapitalHQ/frontend-libraries/blob/98a64d7/packages/exceptions/src/exceptions/base.exception.ts#L27)
Loading

0 comments on commit 8ef4bc8

Please sign in to comment.