diff --git a/registry.go b/registry.go index d0f9e55..9c72355 100644 --- a/registry.go +++ b/registry.go @@ -244,12 +244,12 @@ func (r *AnnotationRegistry) GetTypeAnnotation(t reflect.Type, at reflect.Type) } if 0 == len(td.typeAnnotation) { - return nil, fmt.Errorf("TypeAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } a, ok := td.typeAnnotation[at] if !ok { - return nil, fmt.Errorf("Annotation[%s] of type[%s] is not exist", at.Name(), td.rt.Name()) + return nil, nil } return a, nil @@ -265,7 +265,7 @@ func (r *AnnotationRegistry) GetTypeAnnotations(t reflect.Type) (map[reflect.Typ } if 0 == len(td.typeAnnotation) { - return nil, fmt.Errorf("TypeAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } return td.typeAnnotation, nil @@ -281,17 +281,17 @@ func (r *AnnotationRegistry) GetFieldAnnotation(t reflect.Type, name string, at } if 0 == len(td.fieldAnnotation) { - return nil, fmt.Errorf("FieldAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } as, ok := td.fieldAnnotation[name] if !ok || 0 == len(as) { - return nil, fmt.Errorf("Field[%s] Annotation of type[%s] is not exist", name, td.rt.Name()) + return nil, nil } a, ok := as[at] if !ok { - return nil, fmt.Errorf("Annotation[%s] of field[%s] in type[%s] is not exist", at.Name(), name, td.rt.Name()) + return nil, nil } return a, nil @@ -307,12 +307,12 @@ func (r *AnnotationRegistry) GetFieldAnnotations(t reflect.Type, name string) (m } if 0 == len(td.fieldAnnotation) { - return nil, fmt.Errorf("FieldAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } as, ok := td.fieldAnnotation[name] if !ok || 0 == len(as) { - return nil, fmt.Errorf("Field[%s] Annotation of type[%s] is not exist", name, td.rt.Name()) + return nil, nil } return as, nil @@ -328,7 +328,7 @@ func (r *AnnotationRegistry) GetAllFieldAnnotations(t reflect.Type) (map[string] } if 0 == len(td.fieldAnnotation) { - return nil, fmt.Errorf("FieldAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } return td.fieldAnnotation, nil @@ -344,17 +344,17 @@ func (r *AnnotationRegistry) GetMethodAnnotation(t reflect.Type, name string, at } if 0 == len(td.methodAnnotation) { - return nil, fmt.Errorf("MethodAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } as, ok := td.methodAnnotation[name] if !ok || 0 == len(as) { - return nil, fmt.Errorf("Method[%s] Annotation of type[%s] is not exist", name, td.rt.Name()) + return nil, nil } a, ok := as[at] if !ok { - return nil, fmt.Errorf("Annotation[%s] of method[%s] in type[%s] is not exist", at.Name(), name, td.rt.Name()) + return nil, nil } return a, nil @@ -370,12 +370,12 @@ func (r *AnnotationRegistry) GetMethodAnnotations(t reflect.Type, name string) ( } if 0 == len(td.methodAnnotation) { - return nil, fmt.Errorf("MethodAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } as, ok := td.methodAnnotation[name] if !ok || 0 == len(as) { - return nil, fmt.Errorf("Method[%s] Annotation of type[%s] is not exist", name, td.rt.Name()) + return nil, nil } return as, nil @@ -391,7 +391,7 @@ func (r *AnnotationRegistry) GetAllMethodAnnotations(t reflect.Type) (map[string } if 0 == len(td.methodAnnotation) { - return nil, fmt.Errorf("MethodAnnotation of type[%s] is not exist", td.rt.Name()) + return nil, nil } return td.methodAnnotation, nil