[almighty] Code re-factoring for accessing the errors package in alm-core

Shoubhik Bose shbose at redhat.com
Mon Oct 24 11:34:16 UTC 2016


.. but I'm not sure how that's supposed to work because if simpleError is
non-exported, then this wouldn't work:

simpleErrorObj := models.NewSimpleError("foo")
e := models.InternalError{simpleErrorObj}

"implicit assignment of unexported field 'simpleError' in
models.InternalError literal"


-
Shoubhik


On Mon, Oct 24, 2016 at 4:11 PM, Shoubhik Bose <shbose at redhat.com> wrote:

> Thanks Konrad and Thomas for your inputs:
>
> Having a NewSimpleError(..) looks like a better short-term solution than
> maintaining multiple copies of errors.go
>
> -
> Shoubhik
>
> On Mon, Oct 24, 2016 at 2:21 PM, Thomas Mäder <tmader at redhat.com> wrote:
>
>> There is also https://github.com/almighty/almighty-core/issues/100
>> related to this.
>>
>> On 10/24/2016 10:26 AM, Konrad Kleine wrote:
>>
>> Hi Shoubik,
>>
>> Thomas, Aslak and I discussed that at some point and one possible
>> solution would be to construct errors with methods like NewSimpleError(),
>> NewWhatEverError() that must be written first.
>>
>> I'm not sure what the outcome of our discussion was though. It didn't
>> seem extremely important back then.
>>
>> Regards,
>> Konrad
>>
>> On Fri, Oct 21, 2016 at 10:50 AM, Shoubhik Bose <shbose at redhat.com>
>> wrote:
>>
>>> Hi folks,
>>>
>>> In alm-core we have error types defined inside models/errors.go
>>> https://github.com/almighty/almighty-core/blob/master/models/errors.go
>>>
>>> To construct an error we do a :
>>> InternalError{*s*impleError{err.Error()}}
>>>
>>> which means that we can't access these outside the models package since
>>> simpleError is non-exported.
>>>
>>> What would be the recommended approach for defining and using error
>>> types in other packages?
>>>
>>> Should the packages have their own errors.go ,
>>> or
>>> should we modify models/errors.go to make it usable from outside?
>>>
>>>
>>>
>>> --
>>> Shoubhik
>>>
>>> _______________________________________________
>>> almighty-public mailing list
>>> almighty-public at redhat.com
>>> https://www.redhat.com/mailman/listinfo/almighty-public
>>>
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/almighty-public/attachments/20161024/dfc44e76/attachment.htm>


More information about the almighty-public mailing list