File size: 354 Bytes
c09f67c
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export function isError(
  data: unknown,
): false | { code: string; message: string } {
  if (typeof data !== "object" || data === null || !("error" in data)) {
    return false;
  }

  const tellerError = data as { error: { code: string; message: string } };

  return {
    code: tellerError.error.code,
    message: tellerError.error.message,
  };
}