Skip to content

Commit

Permalink
Applied lints. Reorganized folder structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
simphotonics committed Apr 4, 2024
1 parent 1854bbc commit 4bdca4c
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.3.1
- Applied lints.
- Updated dev dependencies.
- Amended README.md.

## 0.3.0
- Applied lints, updated message formatter `toColorString`.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ termination of the program.
## Usage
To use this library include [exception_templates] as dependency in your `pubspec.yaml` file.

### Highlighting the Exception Context
To highlight the **context** in which the exception/error occured use the classes
[`ExceptionOf<T>`][ExceptionOf<T>] and [`ErrorOf<T>`][ErrorOf<T>].
Hereby, the type argument indicates that the exception occured within a method of the class `T`.
Expand Down Expand Up @@ -73,9 +74,9 @@ void main(List<String> args) async {
print('Feedback: $userFeedback\n');
}
}
```

### Highlighting the Exception Type
To emphasise the exception **type** use:
* [`ExceptionOfType<T>`][ExceptionOfType<T>], where `T extends ExceptionType`,
* [`ErrorOfType<T>`][ErrorOfType<T>] where `T extends ErrorType`.
Expand Down
20 changes: 7 additions & 13 deletions lib/exception_templates.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
/// Provides generic exception and error templates.
///
/// Enables throwing specific errors/exceptions without having to declare
/// new classes.
library exception_templates;

export 'src/utils/color_options.dart';
export 'src/errors/error_of.dart';
export 'src/errors/error_of_type.dart';
export 'src/error_types/error_type.dart';
export 'src/error_types/invalid_identifier.dart';
export 'src/exceptions/exception_of.dart';
export 'src/exceptions/exception_of_type.dart';
export 'src/exception_types/exception_type.dart';
export 'src/error/error_of.dart';
export 'src/error/error_of_type.dart';
export 'src/error/error_type.dart';
export 'src/error/invalid_identifier.dart';
export 'src/exception/exception_of.dart';
export 'src/exception/exception_of_type.dart';
export 'src/exception/exception_type.dart';
export 'src/utils/validators.dart';
4 changes: 2 additions & 2 deletions lib/src/errors/error_of.dart → lib/src/error/error_of.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class ErrorOf<T> extends Error {
/// Message added when the error is thrown.
final Object message;

/// Generic object conveying information about the invalid state.
/// Object conveying information about the invalid state.
final Object invalidState;

/// Generic object conveying information about an expected state.
/// Object conveying information about an expected state.
final Object expectedState;

/// Whether to enable color output.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../error_types/error_type.dart';
import 'error_type.dart';
import '../utils/color_options.dart';

/// Parameterized error template.
Expand All @@ -22,10 +22,10 @@ class ErrorOfType<T extends ErrorType> extends Error {
/// Optional message added when the error is thrown.
final Object message;

/// Generic object conveying information about the invalid state.
/// Object conveying information about the invalid state.
final Object invalidState;

/// Generic object conveying information about an expected state.
/// Object conveying information about an expected state.
final Object expectedState;

/// Set to `ColorOutput.ON` to enable color output to terminal.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ import 'error_type.dart';
///
/// Typically used with source code generators where users
/// provide the name of an identifier as `String`.
abstract class InvalidIdentifier extends ErrorType {}
final class InvalidIdentifier extends ErrorType {}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class ExceptionOf<T> implements Exception {
/// Message added when the error is thrown.
final Object message;

/// Generic object conveying information about the invalid state.
/// Object conveying information about the invalid state.
final Object invalidState;

/// Generic object conveying information about an expected state.
/// Object conveying information about an expected state.
final Object expectedState;

/// Whether to enable color output.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../exception_types/exception_type.dart';
import 'exception_type.dart';
import '../utils/color_options.dart';

/// Parameterized exception template.
Expand All @@ -23,10 +23,10 @@ class ExceptionOfType<T extends ExceptionType> implements Exception {
/// Message added when the error is thrown.
final Object message;

/// Generic object conveying information about the invalid state.
/// Object conveying information about the invalid state.
final Object invalidState;

/// Generic object conveying information about an expected state.
/// Object conveying information about an expected state.
final Object expectedState;

/// Whether to enable color output.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/src/utils/validators.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '../errors/error_of_type.dart';
import '../error_types/invalid_identifier.dart';
import '../error/error_of_type.dart';
import '../error/invalid_identifier.dart';

const reservedWords = {
'abstract',
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: exception_templates

description: Dart exception and error classes with generic type, for
description: Dart exception and error classes with generic type. Enables
throwing, catching, and filtering custom exceptions based on their type
argument.

Expand Down

0 comments on commit 4bdca4c

Please sign in to comment.