hancock

Check-in [36225c7a6f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:model: produce error (not panic) on nil testimony
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 36225c7a6f645727963b587a644866011a1be4b4f79a07aa2f28cb42df29a7c7
User & Date: dnc 2020-01-03 02:30:07
Context
2020-01-03
02:45
cmd/hancock: close store after use check-in: 3ef6a50ce4 user: dnc tags: trunk
02:30
model: produce error (not panic) on nil testimony check-in: 36225c7a6f user: dnc tags: trunk
02:29
store: consistent error when testimony not found; expose closer check-in: d22c07e59b user: dnc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to model/testimony.go.

1
2
3
4
5
6
7
8
..
96
97
98
99
100
101
102



103
104
105
106
107
108
109
110
// Copyright (C) 2019  David N. Cohen

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
................................................................................
		log.Panicf("failed to generate testimony key: %s", err)
	}

	return key
}

func (this *Testimony) Check() error {



	if this.Authority == "" {
		return errors.New("testimony missing authority field")
	}
	if this.Content.String() == "" {
		return errors.New("testimony missing content field")
	}
	return nil
}
|







 







>
>
>








1
2
3
4
5
6
7
8
..
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// Copyright (C) 2019, 2020  David N. Cohen

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
................................................................................
		log.Panicf("failed to generate testimony key: %s", err)
	}

	return key
}

func (this *Testimony) Check() error {
	if this == nil {
		return errors.New("testimony is nil")
	}
	if this.Authority == "" {
		return errors.New("testimony missing authority field")
	}
	if this.Content.String() == "" {
		return errors.New("testimony missing content field")
	}
	return nil
}