<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Peace Ngara on Medium]]></title>
        <description><![CDATA[Stories by Peace Ngara on Medium]]></description>
        <link>https://medium.com/@peacengara?source=rss-c8549cce12b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NgEn8tC4edQEiw7-KIDksg.jpeg</url>
            <title>Stories by Peace Ngara on Medium</title>
            <link>https://medium.com/@peacengara?source=rss-c8549cce12b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:03:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@peacengara/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Google Workspace Organization Policy Administrator especially when using Firebase getting…]]></title>
            <link>https://peacengara.medium.com/google-workspace-organization-policy-administrator-especially-when-using-firebase-getting-7ce0ebabd54f?source=rss-c8549cce12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ce0ebabd54f</guid>
            <dc:creator><![CDATA[Peace Ngara]]></dc:creator>
            <pubDate>Sun, 18 Aug 2024 22:36:00 GMT</pubDate>
            <atom:updated>2024-08-18T22:36:00.755Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Google Workspace Organization Policy Administrator especially when using Firebase getting credentials json</strong></h3><p>Its not been an easy one to get credentials json when using a workspace account but i found a way to generate the new keys the easiest way.||</p><p>By default when a new workspace account is created the disable service key (disableServiceAccountKeyCreation) is already enabled and to remove that you just have to run this in your loud shell..</p><p><strong>First thing is first if you have not set the billing qouta:</strong></p><pre>gcloud config set billing/quota_project {projectid}</pre><p>The {projectid} above is the organisational child in this case the firebase account you ca find it in google service accounts not the main account.</p><p><a href="https://console.cloud.google.com/">https://console.cloud.google.com/</a></p><p>If all is set lets then disable the iam role :</p><pre>gcloud org-policies delete iam.disableServiceAccountKeyCreation --organization={projectid}</pre><p>In this case the project ID os the organisation Project ID</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ce0ebabd54f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JSON API Responses in Laravel Exceptions]]></title>
            <link>https://peacengara.medium.com/json-api-responses-in-laravel-exceptions-25d009c2ea7d?source=rss-c8549cce12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/25d009c2ea7d</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[exception-handling]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[laravel-framework]]></category>
            <category><![CDATA[laravel-development]]></category>
            <dc:creator><![CDATA[Peace Ngara]]></dc:creator>
            <pubDate>Thu, 21 Jan 2021 14:10:46 GMT</pubDate>
            <atom:updated>2021-01-21T14:28:26.987Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_Pqa5hO11PtY8RpCJbODw.png" /><figcaption>Image credit: edureka asset</figcaption></figure><p>One of the few things I struggled with in my development career as a young developer was handling Exceptions properly in Laravel and I know we are so many that might be having the same difficulty.</p><h3>Here is the Scenario</h3><p>When you are writing a class or a Controller and you have a try and catch block like below and you need to throw your own custom exceptions and respond with Json.</p><pre>{<br>        try {<br>            $people = Person::findorFail();<br>        } catch (ModelNotFoundException $exception) {<br>            return response()-&gt;json([&#39;error&#39; =&gt; &#39;NOT FOUND&#39;], 404);<br>        }<br> }</pre><p>Unfortunately the code above will not respond if it’s an API Call as Exceptions pass through a throwable validation interface.</p><h3>The Solution</h3><p>First Create your own custom exceptions using the command below:</p><pre>php artisan make:exception PersonNotFound</pre><p>This will create an Exception class in app/Exceptions like below:</p><pre>&lt;?php<br><br>namespace App\Exceptions;<br><br>use Exception;<br><br>class PersonNotFoundException extends Exception<br>{<br>    //<br>}</pre><p>Its ok to leave it with a blank body as is . Next we go back to our initial Controller and throw this exception.</p><pre>{<br>        try {<br>            $people = Person::findorFail();<br>        } catch (\Exception $exception) {<br>            throw new PersonNotFoundException<br>        }<br> }</pre><p>Now one might be asking at this moment that how do you then send a json response with correct headers on catching the exception. Well here is the answer that saved me nights.</p><blockquote>You have to open app/Exceptions/Handler.php and add the below . Please note in Laravel 8 and up there is no handler public function you can just add the whole function.</blockquote><pre>public function render($request, \Throwable $exception) {<br><br>    if ($exception instanceof PersonNotFoundException) {<br>        return response()-&gt;json(<br>            [<br>                &#39;success&#39; =&gt; false,<br>                &#39;message&#39; =&gt; &quot;Person not found&quot;<br>            ],<br>            400<br>        );<br>    }<br>    return parent::<em>render</em>($request, $exception);<br>}</pre><p>That’s it now you can properly catch all your exceptions and give a nice response to your API’s including Machine to Machine, Single Page Applications and more.</p><p>My Profile <a href="http://www.github.com/Peace-N">github.com/Peace-N</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25d009c2ea7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>