@@ -127,23 +127,25 @@ public function __construct($text, &$client = null)
127
127
128
128
$ this ->version = $ this ->response ->text ('/srw:*/srw:version ' );
129
129
130
- $ e = $ this ->response ->first ('/srw:*/srw:diagnostics ' );
131
- if ($ e ) {
130
+ $ diagnostic = $ this ->response ->first ('/srw:*/srw:diagnostics/d:diagnostic ' );
131
+ if ($ diagnostic ) {
132
132
// Only the 'uri' field is required, 'message' and 'details' are optional
133
- $ uri = $ e ->text ('d:diagnostic/d:uri ' );
134
- $ msg = $ e ->text ('d:diagnostic/d:message ' );
135
- $ details = $ e ->text ('d:diagnostic/d:details ' );
136
- if (empty ($ msg )) {
137
- if (isset (self ::$ errorMessages [$ uri ])) {
138
- $ msg = self ::$ errorMessages [$ uri ];
139
- } else {
140
- $ msg = 'Unknown error ' ;
133
+ $ uri = $ diagnostic ->text ('d:uri ' );
134
+ if (strlen ($ uri )) {
135
+ $ msg = $ diagnostic ->text ('d:message ' );
136
+ $ details = $ diagnostic ->text ('d:details ' );
137
+ if (empty ($ msg )) {
138
+ if (isset (self ::$ errorMessages [$ uri ])) {
139
+ $ msg = self ::$ errorMessages [$ uri ];
140
+ } else {
141
+ $ msg = 'Unknown error ' ;
142
+ }
141
143
}
144
+ if (!empty ($ details )) {
145
+ $ msg .= ' ( ' . $ details . ') ' ;
146
+ }
147
+ throw new Exceptions \SruErrorException ($ msg , $ uri );
142
148
}
143
- if (!empty ($ details )) {
144
- $ msg .= ' ( ' . $ details . ') ' ;
145
- }
146
- throw new Exceptions \SruErrorException ($ msg , $ uri );
147
149
}
148
150
}
149
151
0 commit comments