Skip to content

Commit 950a196

Browse files
committed
Merge branch 'release/1.0.1'
2 parents 5cb914e + a7328b4 commit 950a196

File tree

7 files changed

+44
-13
lines changed

7 files changed

+44
-13
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Changelog
2+
Notable changes to the Fortran Error Handler will be documented here.
3+
4+
## [Unreleased]
5+
6+
## [1.0.1] - 2020-06-30
7+
### Added
8+
- Option to turn off printing of non-critical (warning) errors on trigger. Configured by `triggerWarnings` parameter on `ErrorHandler%init(...)`.
9+
- This CHANGELOG.
10+
11+
### Fixed
12+
- A few corrections to documentation.
13+
14+
## [1.0] - 2020-06-05
15+
### Added
16+
- First major release.
17+
18+
[Unreleased]: https://github.com/samharrison7/fortran-error-handler/tree/develop
19+
[1.0.1]: https://github.com/samharrison7/fortran-error-handler/tree/1.0.1
20+
[1.0]: https://github.com/samharrison7/fortran-error-handler/tree/1.0

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ $ 1
140140
$ Input value is: 1
141141
```
142142

143-
The stop codes 105 and 106 are the default error codes for those particular limit criteria. These codes can be modified using the ErrorCriteria's `modifyErrorCriterionCode` procedure. See the [ErrorCriteria docs](docs/ErrorCriteria.md).
143+
The stop codes 105 and 106 are the default error codes for those particular limit criteria. These codes can be modified using the ErrorCriteria's `modifyErrorCriterionCode` procedure. See the [ErrorCriteria docs](doc/ErrorCriteria.md).
144144

145-
The framework is designed to work seemlessly in large object-oriented projects, where Result objects can be returned from functions with ErrorInstances that contain a user-defined trace of where the error came from. The goal of such a trace is to provide more useful errors to end users of your application, who might not have access to the source code and thus find standard stack traces containing references to files and line numbers useless. More details can be found in the [ErrorInstance docs](docs/ErrorInstance.md), and more thorough examples in the [examples directory](example/).
145+
The framework is designed to work seemlessly in large object-oriented projects, where Result objects can be returned from functions with ErrorInstances that contain a user-defined trace of where the error came from. The goal of such a trace is to provide more useful errors to end users of your application, who might not have access to the source code and thus find standard stack traces containing references to files and line numbers useless. More details can be found in the [ErrorInstance docs](doc/ErrorInstance.md), and more thorough examples in the [examples directory](example/).
146146

147147
## Learn more <a name="more"></a>
148148

doc/ErrorCriteria.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Initialising ErrorCriteria serves the purpose of [initialising its parent](Error
3333
| `character(len=*), optional :: criticalPrefix` | Custom prefix to be prepended to critical error messages. | "Error:" |
3434
| `character(len=*), optional :: warningPrefix` | Custom prefix to non-critical (warning) error messages. | "Warning:" |
3535
| `character(len=*), optional :: messageSuffix` | Custom suffix to be appended to error message. | - |
36-
| `logical, optional :: bashColors` | Should colors be displayed in output to bash consoles? | .true. |
36+
| `logical, optional :: bashColors` | Should colors be displayed in output to bash consoles? | `.true.` |
3737

3838
For example:
3939

doc/ErrorHandler.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ The ErrorHandler must be initialised before use, by calling the `init` procedure
2222
| `character(len=*), optional :: criticalPrefix` | Custom prefix to be prepended to critical error messages. | "Error:" |
2323
| `character(len=*), optional :: warningPrefix` | Custom prefix to non-critical (warning) error messages. | "Warning:" |
2424
| `character(len=*), optional :: messageSuffix` | Custom suffix to be appended to error message. | - |
25-
| `logical, optional :: bashColors` | Should colors be displayed in output to bash consoles? | .true. |
26-
| `logical, optional :: on` | Should the `trigger` procedure actually trigger errors? | .true. |
25+
| `logical, optional :: bashColors` | Should colors be displayed in output to bash consoles? | `.true.` |
26+
| `logical, optional :: printErrorCode` | Should the error code be prepended to the prefix? | `.false.` |
27+
| `logical, optional :: triggerWarnings` | Should warnings be printed when the error queue is triggered? | `.true.` |
28+
| `logical, optional :: on` | Should the `trigger` procedure actually trigger errors? | `.true.` |
2729

2830
For example:
2931

@@ -50,7 +52,7 @@ For single errors, `add` acts as a generic to the ErrorHandler's `addErrorInstan
5052
| :--- | :--- | :--- |
5153
| `integer, optional :: code` | Error code to add. | - |
5254
| `character(len=*), optional :: message` | Message for the error. | "" |
53-
| `logical, optional :: isCritical` | Is the error critical? | .true. |
55+
| `logical, optional :: isCritical` | Is the error critical? | `.true.` |
5456
| `type(ErrorInstance), optional :: error` | ErrorInstance to add, if a code hasn't been specified. | - |
5557

5658
For example:
@@ -67,7 +69,7 @@ For multiple errors input as an array of codes and optional messages and areCrit
6769
| :--- | :--- | :--- |
6870
| `integer :: codes(:)` | Array of error codes to add. | - |
6971
| `character(len=*), optional :: messages(:)` | Corresponding messages for the errors. | "" |
70-
| `logical, optional :: areCritical(:)` | Are the errors critical? | .true. |
72+
| `logical, optional :: areCritical(:)` | Are the errors critical? | `.true.` |
7173

7274
For example:
7375

doc/ErrorInstance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ An `ErrorInstance(code, message, isCritical, trace)` interface is provided so th
1414

1515
| Parameter declaration | Description | Default |
1616
| :--- | :--- | :--- |
17-
| `integer, optional :: code` | The error code. | 1 |
18-
| `character(len=*), optional :: message` | Default message for the error (which there is plenty of opportunity to override). | "" |
19-
| `logical, optional :: isCritical` | Is the error critical (i.e., should it stop the program)? | .true. |
17+
| `integer, optional :: code` | The error code. | `1` |
18+
| `character(len=*), optional :: message` | Default message for the error (which there is plenty of opportunity to override). | `""` |
19+
| `logical, optional :: isCritical` | Is the error critical (i.e., should it stop the program)? | `.true.` |
2020
| `character(len=*), optional :: trace(:)` | Custom trace for the error | - |
2121

2222
For example:

src/ErrorCriteria.f90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,16 @@ subroutine initErrorCriteria(this, &
139139
messageSuffix, &
140140
bashColors, &
141141
printErrorCode, &
142+
triggerWarnings, &
142143
on)
143144
class(ErrorCriteria), intent(inout) :: this !! This ErrorCriteria instance
144145
type(ErrorInstance), intent(in), optional :: errors(:) !! Custom defined errors
145146
character(len=*), intent(in), optional :: criticalPrefix !! Prefix to critical error messages
146147
character(len=*), intent(in), optional :: warningPrefix !! Prefix to warning error messages
147148
character(len=*), intent(in), optional :: messageSuffix !! Suffix to error messages
148149
logical, intent(in), optional :: bashColors !! Should prefixes be colored in bash shells?
149-
logical, intent(in), optional :: printErrorCode
150+
logical, intent(in), optional :: printErrorCode !! Should error messages be prefixed with the error code?
151+
logical, intent(in), optional :: triggerWarnings !! Should warnings be printing on trigger?
150152
logical, intent(in), optional :: on !! Should the ErrorHandler output errors?
151153

152154
! Initialise the parent ErrorHandler
@@ -156,6 +158,7 @@ subroutine initErrorCriteria(this, &
156158
warningPrefix=warningPrefix, &
157159
messageSuffix=messageSuffix, &
158160
bashColors=bashColors, &
161+
triggerWarnings=triggerWarnings, &
159162
printErrorCode=printErrorCode, &
160163
on=on &
161164
)

src/ErrorHandler.f90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module ErrorHandlerModule
1717
logical :: isInitialised = .false. !! Has the ErrorHandler been initialised?
1818
logical :: bashColors = .true. !! Should colors be displayed in bash consoles?
1919
logical :: printErrorCode = .false. !! Should the error code be printed when errors triggered?
20+
logical :: triggerWarnings = .true. !! Should warnings be printed on trigger?
2021
logical :: on = .true. !! Set to .false. to turn ErrorHandler output off
2122

2223
contains
@@ -64,6 +65,7 @@ subroutine initErrorHandler(this, &
6465
messageSuffix, &
6566
bashColors, &
6667
printErrorCode, &
68+
triggerWarnings, &
6769
on)
6870
class(ErrorHandler), intent(inout) :: this !! This ErrorHandler instance
6971
type(ErrorInstance), intent(in), optional :: errors(:) !! List of ErrorInstances to add
@@ -72,6 +74,7 @@ subroutine initErrorHandler(this, &
7274
character(len=*), intent(in), optional :: messageSuffix !! Suffix for error messages
7375
logical, intent(in), optional :: bashColors !! Use bash colours or not?
7476
logical, intent(in), optional :: printErrorCode !! Should the error code be prepended to the prefix?
77+
logical, intent(in), optional :: triggerWarnings !! Should warnings be printed on trigger?
7578
logical, intent(in), optional :: on !! Turn the ErrorHandler on or off
7679
integer :: i ! Loop iterator.
7780
logical, allocatable :: mask(:) ! Logical mask to remove default errors from input errors array.
@@ -137,8 +140,10 @@ subroutine initErrorHandler(this, &
137140
if (this%bashColors .eqv. .true.) this%criticalPrefix = "\x1B[91m" // adjustl(trim(this%criticalPrefix)) // "\x1B[0m"
138141
if (this%bashColors .eqv. .true.) this%warningPrefix = "\x1B[94m" // adjustl(trim(this%warningPrefix)) // "\x1B[0m"
139142

140-
! Set whether we want the error code to be prefix to the message
143+
! Set whether we want the error code to be prefixed to the message and whether
144+
! we want warnings to be triggered
141145
if (present(printErrorCode)) this%printErrorCode = printErrorCode
146+
if (present(triggerWarnings)) this%triggerWarnings = triggerWarnings
142147

143148
! Set whether ErrorHandler output is on or off
144149
if (present(on)) this%on = on
@@ -503,7 +508,8 @@ subroutine trigger(this, code, error, errors)
503508
! print out errors for elements of arrays that mightn't have
504509
! been used (e.g., if the wrong size array was declared). Don't do
505510
! anything if error code is zero.
506-
if (errorsOut(i)%getCode() > 0 .and. errorsOut(i)%getCode() < 99999) then
511+
if (errorsOut(i)%getCode() > 0 .and. errorsOut(i)%getCode() < 99999 &
512+
.and. .not. (.not. this%triggerWarnings .and. .not. errorsOut(i)%isCritical)) then
507513
! Set message prefix according to whether error is
508514
! critical or warning. Also add colour for Bash consoles.
509515
if (errorsOut(i)%isCritical) then

0 commit comments

Comments
 (0)