Skip to content

Commit 40132dd

Browse files
committed
added docs
1 parent 85b4ed8 commit 40132dd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

doc/specs/stdlib_system.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,34 @@ and monitoring of system commands or applications directly from Fortran.
99

1010
[TOC]
1111

12+
## `fs_error` - A derived type for concise error handling
13+
14+
### Status
15+
16+
Experimental
17+
18+
### Description
19+
20+
The derived type contains a `code`, an integer and a fixed-length string containg a user friendly message.
21+
The code is usually the one returned by C functions like `GetLastError` (Windows API) or global variables like `errno` (Unix platforms)
22+
It is default initialized to `0` and it remains so if no errors occured.
23+
In case the error is not because of any C functions, It is always set to `-1` (For distinguishability)
24+
25+
### Type-bound Procedures
26+
27+
The following convenience type-bound procedures are provided:
28+
- `print()` returns a formatted allocatable character string containing the code and the message;
29+
- `ok()` returns a `logical` flag that is `.true.` in case of no errors (`code == 0`);
30+
- `error()` returns a `logical` flag that is `.true.` in case of an error (`code /= 0`).
31+
- `handle([err])` assigns `err` to the calling variable or stops the program by calling `error stop`
32+
33+
### Example
34+
35+
```
36+
fortran
37+
{!example/system/example_fs_error.f90!}
38+
```
39+
1240
## `run` - Execute an external process synchronously
1341

1442
### Status

0 commit comments

Comments
 (0)