certichain

Blockchain built from scratch for verifying document's legitimacy.
Log | Files | Refs | README | LICENSE

commit edf127371ad75bbe919993033e8281a1b1cfde94
parent a2485daf60bc0e2ffd22bddfc221a84690815dd8
Author: Shivakumar <[email protected]>
Date:   Fri,  7 Aug 2026 02:26:59 +0530

fix(api): fix the misleading error, and add return

Signed-off-by: Shivakumar <[email protected]>

Diffstat:
Mapi/handlers/blocks.go | 2+-
Mapi/handlers/institution.go | 4++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/api/handlers/blocks.go b/api/handlers/blocks.go @@ -112,5 +112,5 @@ func writeStorageError(w http.ResponseWriter, err error, msg string) { writeError(w, http.StatusNotFound, "not_found", msg) return } - writeError(w, http.StatusBadRequest, "invalid_body", "invalid hash hex encoding") + writeError(w, http.StatusInternalServerError, "server_error", "internal server error") } diff --git a/api/handlers/institution.go b/api/handlers/institution.go @@ -83,15 +83,19 @@ func GetInstitution(reg *registry.Registry) http.HandlerFunc { DID: did, Registered: true, }) + return case errors.Is(err, storage.ErrNotFound): writeJSON(w, http.StatusOK, &dto.GetInstitutionResponse{ DID: "", Registered: false, }) + return case errors.Is(err, registry.ErrInvalidDID): writeError(w, http.StatusBadRequest, "invalid_did", "malformed DID") + return default: writeError(w, http.StatusInternalServerError, "server_error", "Internal Server Error") + return } } }