Skip to content

Commit 7264a5f

Browse files
committed
added example
1 parent 96eed56 commit 7264a5f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

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)