Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.

Commit e568818

Browse files
author
John Jacquay
committed
Resolves #15 Added better error handling to differentiate between errors and empty meta collections
1 parent f5f4e1f commit e568818

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

lib/build/libgorods.a

16 Bytes
Binary file not shown.

lib/wrapper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ int gorods_meta_collection(char *name, char *cwd, goRodsMetaResult_t* result, rc
916916
status = rcGenQuery(conn, &genQueryInp, &genQueryOut);
917917

918918
if ( status == 0 ) {
919-
*err = "None";
920-
return -1;
919+
*err = "No rows found";
920+
return CAT_NO_ROWS_FOUND;
921921
}
922922

923923
if ( status == CAT_NO_ROWS_FOUND ) {

meta.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (mc *MetaCollection) init() error {
132132
// If MetaCollection hasn't been opened, do it!
133133
if len(mc.Metas) < 1 {
134134
if err := mc.ReadMeta(); err != nil {
135-
//return err
135+
return err
136136
}
137137
}
138138

@@ -160,18 +160,30 @@ func (mc *MetaCollection) ReadMeta() error {
160160

161161
switch mc.Obj.GetType() {
162162
case DataObjType:
163-
cwd := C.CString(mc.Obj.GetCol().Path)
163+
cwdGo := mc.Obj.GetCol().Path
164+
cwd := C.CString(cwdGo)
165+
164166
defer C.free(unsafe.Pointer(cwd))
165167

166168
if status := C.gorods_meta_dataobj(name, cwd, &metaResult, mc.Con.ccon, &err); status != 0 {
167-
return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v", cwd, C.GoString(err)))
169+
if status == C.CAT_NO_ROWS_FOUND {
170+
return nil
171+
} else {
172+
return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v, %v", cwdGo, C.GoString(err), status))
173+
}
168174
}
169175
case CollectionType:
170-
cwd := C.CString(filepath.Dir(mc.Obj.GetPath()))
176+
cwdGo := filepath.Dir(mc.Obj.GetPath())
177+
cwd := C.CString(cwdGo)
178+
171179
defer C.free(unsafe.Pointer(cwd))
172180

173181
if status := C.gorods_meta_collection(name, cwd, &metaResult, mc.Con.ccon, &err); status != 0 {
174-
return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v", cwd, C.GoString(err)))
182+
if status == C.CAT_NO_ROWS_FOUND {
183+
return nil
184+
} else {
185+
return newError(Fatal, fmt.Sprintf("iRods Get Meta Failed: %v, %v, %v", cwdGo, C.GoString(err), status))
186+
}
175187
}
176188
case ResourceType:
177189

0 commit comments

Comments
 (0)