Skip to content

Commit

Permalink
Added ObjectDisposedException and fixed README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Wassenhoven committed Mar 4, 2022
1 parent a77770b commit 78a0a58
Show file tree
Hide file tree
Showing 23 changed files with 126 additions and 79 deletions.
1 change: 1 addition & 0 deletions Code/src/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from './NotFoundException';
export * from './NotImplementedException';
export * from './NotPermittedException';
export * from './NotSupportedException';
export * from './ObjectDisposedException';
export * from './OperationAbortedException';
export * from './TimeoutException';
export * from './ValidationException';
27 changes: 27 additions & 0 deletions Code/src/ObjectDisposedException.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {InvalidOperationException} from './InvalidOperationException';

/**
* Exception that will be thrown if an operation is invalid because the object is already disposed.
*/
export class ObjectDisposedException extends InvalidOperationException {
private readonly _objectName: symbol;

public constructor(objectName: string, cause?: Error);
public constructor(objectName: string, message?: string, cause?: Error);
public constructor(objectName: string, messageOrCause?: string | Error, cause?: Error) {
super(
typeof messageOrCause === 'string' ?
messageOrCause :
'Cannot access a disposed object.',
typeof messageOrCause === 'string' || cause ?
cause :
messageOrCause
);
this._objectName = Symbol('Object name');
this.data[this._objectName] = objectName;
}

public get objectName(): string {
return this.data[this._objectName];
}
}
2 changes: 1 addition & 1 deletion Docs/assets/search.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/AggregateException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/ArgumentException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/ArgumentNullException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/ArgumentOutOfRangeException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/ChuckNorrisException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/Exception.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/IOException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/InvalidFormatException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/InvalidOperationException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/NotFoundException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/NotImplementedException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/NotPermittedException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/NotSupportedException.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Docs/classes/ObjectDisposedException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/OperationAbortedException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/TimeoutException.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Docs/classes/ValidationException.html

Large diffs are not rendered by default.

39 changes: 23 additions & 16 deletions Docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Docs/modules.html

Large diffs are not rendered by default.

66 changes: 37 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ follow this link: [Docs](https://htmlpreview.github.io/?https://raw.githubuserco
Baseclass of all other exception classes.
```
import {Exception} from 'grexcept';
new Exception(message: string, innerException?: Error)
new Exception(message: string, cause?: Error)
Exception.fromObject(ex: any): Error
// wrapps object inside a exception object if object is not already a exception or error
Expand All @@ -37,32 +37,32 @@ Exception.isError(ex: any): ex is Error
Exception that will be thrown if multiple errors occurred.
```
import {AggregateException} from 'grexcept';
new AggregateException(innerException: Error | Error[], message?: string)
new AggregateException(innerException: Error | Error[])
new AggregateException(innerExceptions: Error | Error[], message?: string)
new AggregateException(innerExceptions: Error | Error[])
```

### ArgumentException
Exception that will be thrown if a value is invalid.
```
import {ArgumentException} from 'grexcept';
new ArgumentException(argumentName: PropertyKey, message?: string, innerException?: Error)
new ArgumentException(argumentName: PropertyKey, innerException?: Error)
new ArgumentException(argumentName: PropertyKey, message?: string, cause?: Error)
new ArgumentException(argumentName: PropertyKey, cause?: Error)
```

### ArgumentNullException
Exception that will be thrown if a value is null or undefined.
```
import {ArgumentNullException} from 'grexcept';
new ArgumentNullException(argumentName: PropertyKey, message?: string, innerException?: Error)
new ArgumentNullException(argumentName: PropertyKey, innerException?: Error)
new ArgumentNullException(argumentName: PropertyKey, message?: string, cause?: Error)
new ArgumentNullException(argumentName: PropertyKey, cause?: Error)
```

### ArgumentOutOfRangeException
Exception that will be thrown if a value is out of a range.
```
import {ArgumentOutOfRangeException} from 'grexcept';
new ArgumentOutOfRangeException(argumentName: PropertyKey, actualValue: any, message?: string, innerException?: Error)
new ArgumentOutOfRangeException(argumentName: PropertyKey, actualValue: any, innerException?: Error)
new ArgumentOutOfRangeException(argumentName: PropertyKey, actualValue: any, message?: string, cause?: Error)
new ArgumentOutOfRangeException(argumentName: PropertyKey, actualValue: any, cause?: Error)
```

### ChuckNorrisException
Expand All @@ -76,77 +76,85 @@ new ChuckNorrisException(exceptionObject: any)
Exception that will be thrown if a call of a method is invalid because of the current state of the object.
```
import {InvalidOperationException} from 'grexcept';
new InvalidOperationException(message?: string, innerException?: Error)
new InvalidOperationException(innerException?: Error)
new InvalidOperationException(message?: string, cause?: Error)
new InvalidOperationException(cause?: Error)
```

### InvalidFormatException
Exception that will be thrown if an object or string doesn't fulfill the excepted format.
```
import {InvalidFormatException} from 'grexcept';
new InvalidFormatException(message?: string, innerException?: Error)
new InvalidFormatException(innerException?: Error)
new InvalidFormatException(message?: string, cause?: Error)
new InvalidFormatException(cause?: Error)
```

### IOException
Exception that will be thrown if an input or output error occurred.
```
import {IOException} from 'grexcept';
new IOException(message?: string, innerException?: Error)
new IOException(innerException?: Error)
new IOException(message?: string, cause?: Error)
new IOException(cause?: Error)
```

### NotFoundException
Exception that will be thrown if some resource or entity was not found.
```
import {NotFoundException} from 'grexcept';
new NotFoundException(entity: string | (new (...args: any[]) => any), message?: string, innerException?: Error)
new NotFoundException(entity: string | (new (...args: any[]) => any), innerException?: Error)
new NotFoundException(entity: string | (new (...args: any[]) => any), message?: string, cause?: Error)
new NotFoundException(entity: string | (new (...args: any[]) => any), cause?: Error)
```

### NotImplementedException
Exception that will be thrown if some method or operation is not implemented.
```
import {NotImplementedException} from 'grexcept';
new NotImplementedException(message?: string, innerException?: Error)
new NotImplementedException(innerException?: Error)
new NotImplementedException(message?: string, cause?: Error)
new NotImplementedException(cause?: Error)
```

### NotPermittedException
Exception that will be thrown if the callee is not permitted to execute this method or operation.
```
import {NotPermittedException} from 'grexcept';
new NotPermittedException(message?: string, innerException?: Error)
new NotPermittedException(innerException?: Error)
new NotPermittedException(message?: string, cause?: Error)
new NotPermittedException(cause?: Error)
```

### NotSupportedException
Exception that will be thrown if the called method or operation is not supported.
```
import {NotSupportedException} from 'grexcept';
new NotSupportedException(message?: string, innerException?: Error)
new NotSupportedException(innerException?: Error)
new NotSupportedException(message?: string, cause?: Error)
new NotSupportedException(cause?: Error)
```

### ObjectDisposedException
Exception that will be thrown if an operation is invalid because the object is already disposed.
```
import {ObjectDisposedException} from 'grexcept';
new ObjectDisposedException(objectName: string, message?: string, cause?: Error)
new ObjectDisposedException(objectName: string, cause?: Error)
```

### OperationAbortedException
```
import {OperationAbortedException} from 'grexcept';
new OperationAbortedException(reason?: string, innerException?: Error)
new OperationAbortedException(innerException?: Error)
new OperationAbortedException(reason?: string, cause?: Error)
new OperationAbortedException(cause?: Error)
```

### TimeoutException
Exception that will be thrown if a timeout has been reached and an operation was canceled.
```
import {TimeoutException} from 'grexcept';
new TimeoutException(timeout: number, reason?: string, innerException?: Error)
new TimeoutException(timeout: number, innerException?: Error)
new TimeoutException(timeout: number, reason?: string, cause?: Error)
new TimeoutException(timeout: number, cause?: Error)
```

### ValidationException
Exception that will be thrown if a validation of some argument failed.
```
import {ValidationException} from 'grexcept';
new ValidationException(message?: string, innerException?: Error)
new ValidationException(innerException?: Error)
new ValidationException(message?: string, cause?: Error)
new ValidationException(cause?: Error)
```

0 comments on commit 78a0a58

Please sign in to comment.