@@ -719,40 +719,45 @@ subroutine check_and_read_pkg_data(json, node, download_url, version, error)
719
719
720
720
integer :: code, stat
721
721
type (json_object), pointer :: p, q
722
- character (:), allocatable :: version_key, version_str, error_message
722
+ character (:), allocatable :: version_key, version_str, error_message, namespace, name
723
+
724
+ namespace = " "
725
+ name = " UNNAMED_NODE"
726
+ if (allocated (node% namespace)) namespace = node% namespace
727
+ if (allocated (node% name)) name = node% name
723
728
724
729
if (.not. json% has_key(' code' )) then
725
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': No status code." ); return
730
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': No status code." ); return
726
731
end if
727
732
728
733
call get_value(json, ' code' , code, stat= stat)
729
734
if (stat /= 0 ) then
730
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': " // &
735
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': " // &
731
736
& " Failed to read status code." ); return
732
737
end if
733
738
734
739
if (code /= 200 ) then
735
740
if (.not. json% has_key(' message' )) then
736
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': No error message." ); return
741
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': No error message." ); return
737
742
end if
738
743
739
744
call get_value(json, ' message' , error_message, stat= stat)
740
745
if (stat /= 0 ) then
741
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': " // &
746
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': " // &
742
747
& " Failed to read error message." ); return
743
748
end if
744
749
745
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " '. Status code: '" // &
750
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " '. Status code: '" // &
746
751
& str(code)// " '. Error message: '" // error_message// " '." ); return
747
752
end if
748
753
749
754
if (.not. json% has_key(' data' )) then
750
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': No data." ); return
755
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': No data." ); return
751
756
end if
752
757
753
758
call get_value(json, ' data' , p, stat= stat)
754
759
if (stat /= 0 ) then
755
- call fatal_error(error, " Failed to read package data for '" // join_path(node % namespace, node % name)// " '." ); return
760
+ call fatal_error(error, " Failed to read package data for '" // join_path(namespace, name)// " '." ); return
756
761
end if
757
762
758
763
if (allocated (node% requested_version)) then
@@ -762,38 +767,38 @@ subroutine check_and_read_pkg_data(json, node, download_url, version, error)
762
767
end if
763
768
764
769
if (.not. p% has_key(version_key)) then
765
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': No version data." ); return
770
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': No version data." ); return
766
771
end if
767
772
768
773
call get_value(p, version_key, q, stat= stat)
769
774
if (stat /= 0 ) then
770
- call fatal_error(error, " Failed to retrieve version data for '" // join_path(node % namespace, node % name)// " '." ); return
775
+ call fatal_error(error, " Failed to retrieve version data for '" // join_path(namespace, name)// " '." ); return
771
776
end if
772
777
773
778
if (.not. q% has_key(' download_url' )) then
774
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': No download url." ); return
779
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': No download url." ); return
775
780
end if
776
781
777
782
call get_value(q, ' download_url' , download_url, stat= stat)
778
783
if (stat /= 0 ) then
779
- call fatal_error(error, " Failed to read download url for '" // join_path(node % namespace, node % name)// " '." ); return
784
+ call fatal_error(error, " Failed to read download url for '" // join_path(namespace, name)// " '." ); return
780
785
end if
781
786
782
787
download_url = official_registry_base_url// download_url
783
788
784
789
if (.not. q% has_key(' version' )) then
785
- call fatal_error(error, " Failed to download '" // join_path(node % namespace, node % name)// " ': No version found." ); return
790
+ call fatal_error(error, " Failed to download '" // join_path(namespace, name)// " ': No version found." ); return
786
791
end if
787
792
788
793
call get_value(q, ' version' , version_str, stat= stat)
789
794
if (stat /= 0 ) then
790
- call fatal_error(error, " Failed to read version data for '" // join_path(node % namespace, node % name)// " '." ); return
795
+ call fatal_error(error, " Failed to read version data for '" // join_path(namespace, name)// " '." ); return
791
796
end if
792
797
793
798
call new_version(version, version_str, error)
794
799
if (allocated (error)) then
795
800
call fatal_error(error, " '" // version_str// " ' is not a valid version for '" // &
796
- & join_path(node % namespace, node % name)// " '." ); return
801
+ & join_path(namespace, name)// " '." ); return
797
802
end if
798
803
end subroutine
799
804
0 commit comments