Skip to content

Commit 4d1e6d0

Browse files
committed
added example
1 parent 96eed56 commit 4d1e6d0

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

doc/specs/stdlib_system.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ An arbitrary list of `integer`, `real`, `complex`, or `character` variables. Num
442442

443443
### Behavior
444444

445-
Formats all the arguments into a nice error message, utilising the constructor of [[stdlib_system(module):state_type(type)]]
445+
Formats all the arguments into a nice error message, utilizing the constructor of [[stdlib_system(module):state_type(type)]]
446446

447447
### Return values
448448

@@ -481,7 +481,7 @@ An arbitrary list of `integer`, `real`, `complex`, or `character` variables. Num
481481

482482
### Behavior
483483

484-
Formats all the arguments into a nice error message, utilising the constructor of [[stdlib_system(module):state_type(type)]]
484+
Formats all the arguments into a nice error message, utilizing the constructor of [[stdlib_system(module):state_type(type)]]
485485

486486
### Return values
487487

example/system/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ ADD_EXAMPLE(process_5)
1111
ADD_EXAMPLE(process_6)
1212
ADD_EXAMPLE(process_7)
1313
ADD_EXAMPLE(sleep)
14+
ADD_EXAMPLE(fs_error)

example/system/example_fs_error.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
! Demonstrate usage of `fs_error`, `fs_error_code`
2+
program example_fs_error
3+
use stdlib_system, only: fs_error, fs_error_code
4+
use stdlib_error, only: state_type, STDLIB_FS_ERROR
5+
implicit none
6+
7+
type(state_type) :: err0, err1
8+
9+
err0 = fs_error("Could not create directory", "`temp.dir`", "- Already exists")
10+
11+
if (err0%state == STDLIB_FS_ERROR) then
12+
! Error encountered: Filesystem Error: Could not create directory `temp.dir` - Already exists
13+
print *, err0%print()
14+
end if
15+
16+
err1 = fs_error_code(1, "Could not create directory", "`temp.dir`", "- Already exists")
17+
18+
if (err1%state == STDLIB_FS_ERROR) then
19+
! Error encountered: Filesystem Error: code - 1, Could not create directory `temp.dir` - Already exists
20+
print *, err1%print()
21+
end if
22+
23+
end program example_fs_error

0 commit comments

Comments
 (0)